Sign-in form factory.
@return Form
328307
protected function createComponentSignInForm()
    {
        $form = new Form();
        $form->setRenderer(new BootstrapRenderer());
        $form->addProtection();
        $form->addText('username', $this->translator->translate('users.frontend.sign_in.username.label'))
            ->setType('email')
            ->setAttribute('autofocus')
            ->setRequired($this->translator->translate('users.frontend.sign_in.username.required'))
            ->setAttribute('placeholder', $this->translator->translate('users.frontend.sign_in.username.placeholder'));

        $form->addPassword('password', $this->translator->translate('users.frontend.sign_in.password.label'))
            ->setRequired($this->translator->translate('users.frontend.sign_in.password.required'))
            ->setAttribute('placeholder', $this->translator->translate('users.frontend.sign_in.password.required'));

        $form->addCheckbox('remember', $this->translator->translate('users.frontend.sign_in.remember'));

        $form->addSubmit('send', $this->translator->translate('users.frontend.sign_in.submit'));

        $form->setDefaults([
            'remember' => true,
        ]);

        $form->onSuccess[] = [$this, 'signInFormSucceeded'];
        return $form;
    }
312574
protected function createComponentEditForm(): Form
	{
		$form = $this->formFactory->create();

		$form->addHidden('parent');

		$form->addCheckbox('isLink', 'webManager.web.pages.isLink')
			->setOption('id', 'page-isLink')
			->addCondition($form::EQUAL, false)
			->toggle('page-title')
			->toggle('page-keywords')
			->toggle('page-image')
			->toggle('page-background')
			->toggle('page-description')
			->toggle('page-content')
			->toggle('page-homePage');

		$homePage = $form->addCheckbox('homePage', 'webManager.web.pages.homePage')
			->setOption('id', 'page-homePage')
			->setDisabled(!$this->editHomePage);
		$homePage->addCondition($form::EQUAL, false)
			->toggle('page-name')
			->toggle('page-url')
			->toggle('page-views')
			->toggle('page-isLink');
		if ($homePage->isDisabled()) {
			$homePage->setOption('class', 'hidden');
		}

		$form->addText('name', 'webManager.web.pages.name')
			->setOption('id', 'page-name')
			->addConditionOn($form['homePage'], $form::EQUAL, false)
			->setRequired();

		$form->addText('url', 'default.url')
			->setOption('id', 'page-url')
			->addConditionOn($form['isLink'], $form::EQUAL, true)
			->setRequired();

		$form->addSelectUntranslated('locale', 'webManager.web.pages.locale')
			->setItems($this->localeService->allowed);

		$form->addCheckboxListUntranslated('views', 'webManager.web.pages.views.title')
			->setOption('id', 'page-views')
			->setItems($this->orm->pagesViews->fetchPairsById());

		$form->addText('title', 'webManager.web.pages.pageTitle')
			->setOption('id', 'page-title')
			->setRequired(false)
			->addRule(Form::MAX_LENGTH, null, 150);

		$form->addTextArea('keywords', 'webManager.web.pages.keywords')
			->setOption('id', 'page-keywords')
			->setRequired(false)
			->addRule(Form::MAX_LENGTH, null, 255);

		$form->addImageUpload('image', 'webManager.web.pages.photo', 'webManager.web.pages.photoDelete')
			->setNamespace('pages')
			->setPreview('300x100')
			->setOption('id', 'page-image');

		$form->addColor('background', 'webManager.web.pages.background')
			->setOption('id', 'page-background');

		$form->addTextArea('description', 'webManager.web.pages.description')
			->setOption('id', 'page-description')
			->setRequired(false)
			->addRule(Form::MAX_LENGTH, null, 255);

		$form->addTextEditor('content', 'webManager.web.pages.content')
			->setOption('id', 'page-content');

		$form->addSubmit('save', 'form.save');

		$form->addLink('back', 'form.back', $this->getBacklink());

		$form->onSuccess[] = [$this, 'editFormSucceeded'];

		return $form;
	}
159356
private function authenticate()
    {
        $form = new RemoteIdentityForm;
        $form->attributes = array(
            'adapter'  => $this->getUserProfile(),
            'provider' => $this->getProvider()
        );

        return $form->login();
    }
514745
def login_form_factory(Form, app):
    """"""
    class LoginForm(Form):

        def __init__(self, *args, **kwargs):
            """Init the login form.

            .. note::

                The ``remember me`` option will be completely disabled.
            """
            super(LoginForm, self).__init__(*args, **kwargs)
            self.remember.data = False

    return LoginForm
42277
protected function createComponentUserForm(): Form
	{
		$form = $this->formFactory->create();
		$form->setAjaxRequest();

		$form->addProtection();

		$form->addText('username', 'cms.user.username')
			->setDisabled()
			->setDefaultValue($this->profile->username);
		$form->addText('roles', 'cms.permissions.roles')
			->setDisabled()
			->setDefaultValue(implode(', ', $this->profile->roleTitles));
		$form->addText('firstName', 'cms.user.firstName')
			->setDefaultValue($this->profile->firstName);
		$form->addText('surname', 'cms.user.surname')
			->setDefaultValue($this->profile->surname);
		$form->addText('email', 'cms.user.email')
			->setDefaultValue($this->profile->email)
			->setRequired()
			->addRule(Form::EMAIL);
		$form->addPhone('phone', 'cms.user.phone')
			->setDefaultValue($this->profile->phone);

		$language = $form->addSelectUntranslated('language', 'cms.user.language', $this->localeService->allowed, 'form.none');
		$locale = $this->localeService->get($this->profile->language);
		if ($locale) {
			$language->setDefaultValue($locale->id);
		}

		$form->addSubmit('save', 'form.save');

		$form->onError[] = function (Form $form) {
			if ($this->isAjax()) {
				$this->redrawControl('userForm');
			}
		};

		$form->onSuccess[] = [$this, 'userFormSucceeded'];

		return $form;
	}
257713
public function actionCreate()
    {
        $model = new AuthItem(null);
        $model->type = Item::TYPE_ROLE;
        if (\Yii::$app->request->isAjax && !\Yii::$app->request->isPjax) {
            $model->load(\Yii::$app->request->post());
            \Yii::$app->response->format = Response::FORMAT_JSON;
            return ActiveForm::validate($model);
        }
        if ($model->load(Yii::$app->getRequest()->post()) && $model->save()) {
            return $this->redirect(['view', 'id' => $model->name]);
        } else {
            return $this->render('create', ['model' => $model,]);
        }
    }
1129741
public function actionSignin(){
        $this->layout = '@vendor/cubiclab/admin-cube/views/layouts/signin';

        if (!Yii::$app->user->isGuest) {
            $this->goHome();
        }

        /** @var \cubiclab\users\models\forms\SigninForm $model */
        $model = new SigninForm();
        if ($model->load(Yii::$app->request->post()) && $model->login($this->module->loginDuration)) {
            $loginRedirect = $this->module->loginRedirect;
            if ($loginRedirect === null) {
                return $this->goHome();
            } else {
                return $this->goBack($this->module->loginRedirect);
            }
        }

        // render view
        return $this->render(
            'signin',
            [
                'model' => $model,
            ]
        );
    }
437166
public function form() {
		if(is_null($this->registration_form)) {
			$this->registration_form = new Form();
			$this->registration_form->registerTemplate();
			$this->registerFeature('jabber:iq:register');
		}
		return $this->registration_form;
	}
1245410
protected function createComponentSettingsForm(): Form
	{
		$form = $this->formFactory->create();

		$form->addImageUpload('logo', 'webManager.web.settings.logo', 'webManager.web.settings.deleteLogo')
			->setNamespace('front')
			->setPreview('300x100');
		$form->addText('title', 'webManager.web.settings.pagesTitle');
		$form->addTextArea('keywords', 'webManager.web.settings.keywords');
		$form->addTextArea('description', 'webManager.web.settings.description');

		$form->addSubmit('save', 'form.save');

		$form->onSuccess[] = [$this, 'settingsFormSucceeded'];

		return $form;
	}
1351505
public function actionSignup()
    {
        $model = new SignupForm();
        if ($model->load(Yii::$app->getRequest()->post())) {
            if ($user = $model->signup()) {
                if (Yii::$app->getUser()->login($user)) {
                    return $this->goHome();
                }
            }
        }

        return $this->render('signup', [
            'model' => $model,
        ]);
    }
474089
public function getFormService()
    {
        if (!array_key_exists('form', $this->services)) {
            $this->services['form'] = new Form($this->httpClient, $this->key);
        }

        return $this->services['form'];
    }
259434
protected function createComponentEditForm(): Form
	{
		$form = $this->formFactory->create();

		$form->addText('name', 'default.name')
			->setRequired();

		if ($this->editConst) {
			$form->addText('const', 'webManager.web.content.const')
				->setRequired();

			$form->addSelectUntranslated('locale', 'webManager.web.pages.locale')
				->setItems($this->localeService->allowed);
		}

		$form->addText('title', 'webManager.web.content.contentTitle')
			->addRule(Form::MAX_LENGTH, null, 150)
			->setRequired(false);

		$form->addTextArea('keywords', 'webManager.web.content.keywords');

		$form->addImageUpload('image', 'webManager.web.content.photo', 'webManager.web.content.photoDelete')
			->setNamespace('content')
			->setPreview('300x100');

		$form->addColor('background', 'webManager.web.content.background');

		$form->addTextArea('description', 'webManager.web.content.description');

		$form->addTextEditor('content', 'webManager.web.content.content');

		$form->addSubmit('save', 'form.save');

		$form->addLink('back', 'form.back', $this->getBacklink());

		$form->onSuccess[] = [$this, 'editFormSucceeded'];

		return $form;
	}
505205
public function getAuthFactory(): ?Factory
    {
        if (!$this->hasAuthFactory()) {
            $this->setAuthFactory($this->getDefaultAuthFactory());
        }
        return $this->authFactory;
    }
247542
public function loginAction()
    {
        if ($user = $this->identity()) {
            return $this->redirect()->toRoute($this->getOptions()->getLoginRedirectRoute());
        }
        
        $user = new User;
        $form = $this->getUserFormHelper()->createUserForm($user, 'login');
        $messages = null;
        if ($this->getRequest()->isPost()) {
            $form->setValidationGroup('usernameOrEmail', 'password', 'rememberme', 'csrf', 'captcha');
            $form->setData($this->getRequest()->getPost());
            if ($form->isValid()) {
                $data = $form->getData();
                $authService = $this->getServiceLocator()->get('Zend\Authentication\AuthenticationService');
                $adapter = $authService->getAdapter();
                $usernameOrEmail = $this->params()->fromPost('usernameOrEmail');

                try {
                    $user = $this->getEntityManager()->createQuery("SELECT u FROM CsnUser\Entity\User u WHERE u.email = '$usernameOrEmail' OR u.username = '$usernameOrEmail'")->getResult(\Doctrine\ORM\Query::HYDRATE_OBJECT);
                    $user = $user[0];
                    
                    if(!isset($user)) {
                        $message = 'The username or email is not valid!';
                        return new ViewModel(array(
                            'error' => $this->getTranslatorHelper()->translate('Your authentication credentials are not valid'),
                            'form'	=> $form,
                            'messages' => $messages,
                            'navMenu' => $this->getOptions()->getNavMenu()
                        ));
                    }
                    
                    if($user->getState()->getId() < 2) {
                        $messages = $this->getTranslatorHelper()->translate('Your username is disabled. Please contact an administrator.');
                        return new ViewModel(array(
                            'error' => $this->getTranslatorHelper()->translate('Your authentication credentials are not valid'),
                            'form'	=> $form,
                            'messages' => $messages,
                            'navMenu' => $this->getOptions()->getNavMenu()
                        ));
                    }

                    $adapter->setIdentityValue($user->getUsername());
                    $adapter->setCredentialValue($this->params()->fromPost('password'));

                    $authResult = $authService->authenticate();
                    if ($authResult->isValid()) {
                        $identity = $authResult->getIdentity();
                        $authService->getStorage()->write($identity);
                        
                        if ($this->params()->fromPost('rememberme')) {
                            $time = 1209600; // 14 days (1209600/3600 = 336 hours => 336/24 = 14 days)
                            $sessionManager = new SessionManager();
                            $sessionManager->rememberMe($time);
                        }

                        return $this->redirect()->toRoute($this->getOptions()->getLoginRedirectRoute());
                    }
                    
                    foreach ($authResult->getMessages() as $message) {
                      $messages .= "$message\n";
                    }
                } catch (\Exception $e) {
                    return $this->getServiceLocator()->get('csnuser_error_view')->createErrorView(
                        $this->getTranslatorHelper()->translate('Something went wrong during login! Please, try again later.'),
                        $e,
                        $this->getOptions()->getDisplayExceptions(),
                        $this->getOptions()->getNavMenu()
                    );
                }
            }
        }
        
        return new ViewModel(array(
            'error' => $this->getTranslatorHelper()->translate('Your authentication credentials are not valid'),
            'form'	=> $form,
            'messages' => $messages,
            'navMenu' => $this->getOptions()->getNavMenu()
        ));
    }
146568
public static function factory($config = array())
	{
		$default = array();
		$required = array('base_url');
		$config = Inspector::prepareConfig($config, $default, $required);
		$client = new self($config->get('base_url'), $config->get('token'));
		$client->setConfig($config);
		$client->getEventDispatcher()->addSubscriber(new AuthenticationObserver());
		return $client;
	}
20940
protected function createActivationForm(): FormInterface
    {
        return $this->createFormBuilder(null, ['translation_domain' => 'ngsite_user'])
            ->add(
                'email',
                EmailType::class,
                [
                    'constraints' => [
                        new Constraints\Email(),
                        new Constraints\NotBlank(),
                    ],
                ]
            )->getForm();
    }
1336752
public function signupAction()
    {
        $form = new SignUpForm();

        if ($this->request->isPost()) {

            if ($form->isValid($this->request->getPost()) != false) {

                $user = new Users([
                    'name' => $this->request->getPost('name', 'striptags'),
                    'email' => $this->request->getPost('email'),
                    'password' => $this->security->hash($this->request->getPost('password')),
                    'profilesId' => 2
                ]);

                if ($user->save()) {
//                    return $this->dispatcher->forward([
//                        'namespace' => 'Modules\Frontend\Controllers',
//                        'controller' => 'index',
//                        'action' => 'index'
//                    ]);
                    return $this->response->redirect('index');
                }

                $this->flash->error($user->getMessages());
            }
        }

        $this->view->form = $form;
    }