Factory method for the lost password form

@return Form Returns the lost password form
973039
public function lostPasswordForm()
    {
        $loginFieldLabel = (Config::inst()->get(LDAPAuthenticator::class, 'allow_email_login') === 'yes') ?
            _t('SilverStripe\\LDAP\\Forms\\LDAPLoginForm.USERNAMEOREMAIL', 'Username or email') :
            _t('SilverStripe\\LDAP\\Forms\\LDAPLoginForm.USERNAME', 'Username');
        $loginField = TextField::create('Login', $loginFieldLabel);

        $action = FormAction::create(
            'forgotPassword',
            _t('SilverStripe\\Security\\Security.BUTTONSEND', 'Send me the password reset link')
        );
        return LostPasswordForm::create(
            $this,
            $this->authenticatorClass,
            'LostPasswordForm',
            FieldList::create([$loginField]),
            FieldList::create([$action]),
            false
        );
    }
1346308
protected function formPasswordInfo()
	{
		$form = new XmlFormCollection($this->_context, $this->_url, $this->_myWords->Value("CHANGEPASSTITLE"));
		$this->_paragraph->addXmlnukeObject($form);
		
		$hidden = new XmlInputHidden("action", "changepassword");
		$form->addXmlnukeObject($hidden);
		
		$textbox = new XmlInputTextBox($this->_myWords->Value("CHANGEPASSOLDPASS"), "oldpassword","");
		$textbox->setInputTextBoxType(InputTextBoxType::PASSWORD );
		$form->addXmlnukeObject($textbox);
		
		$textbox = new XmlInputTextBox($this->_myWords->Value("CHANGEPASSNEWPASS"), "newpassword","");
		$textbox->setInputTextBoxType(InputTextBoxType::PASSWORD );
		$form->addXmlnukeObject($textbox);
		
		$textbox = new XmlInputTextBox($this->_myWords->Value("CHANGEPASSNEWPASS2"), "newpassword2","");
		$textbox->setInputTextBoxType(InputTextBoxType::PASSWORD );
		$form->addXmlnukeObject($textbox);
		
		$button = new XmlInputButtons();
		$button->addSubmit($this->_myWords->Value("TXT_CHANGE"),"");
		$form->addXmlnukeObject($button);
	}
20411
protected function createComponentSignInForm()
    {
        $form = $this->createForm();

        $form->addText('username', 'Username')
            ->setRequired('Please provide a username.')
            ->setAttribute('placeholder', $this->translation['Username']);

        $form->addPassword('password', 'Password')
            ->setRequired('Please provide a password.')
            ->setAttribute('placeholder', $this->translation['Password']);

        $form->addCheckbox('remember', 'Permanent login?');

        $form->addSubmit('send', 'Log in');

        $form->onSuccess[] = callback($this, 'signInFormSubmitted');

        return $form;
    }
727435
public function getOldPasswordElement()
    {
        $element = $this->getElement($this->_oldPasswordFieldName);

        if (! $element) {
            // Field current password
            $element = new \Zend_Form_Element_Password($this->_oldPasswordFieldName);
            $element->setLabel($this->_('Current password'));
            $element->setAttrib('size', 40);
            $element->setRenderPassword(true);
            $element->setRequired(true);
            $element->addValidator(
                    new \Gems_User_Validate_UserPasswordValidator($this->user, $this->_('Wrong password.'))
                    );

            $this->addElement($element);
        }

        return $element;
    }
1010593
public function actionRequestPasswordReset()
    {
        $model = new PasswordResetRequest();
        if ($model->load(Yii::$app->getRequest()->post()) && $model->validate()) {
            if ($model->sendEmail()) {
                Yii::$app->getSession()->setFlash('success', 'Check your email for further instructions.');

                return $this->goHome();
            } else {
                Yii::$app->getSession()->setFlash('error', 'Sorry, we are unable to reset password for email provided.');
            }
        }

        return $this->render('requestPasswordResetToken', [
                'model' => $model,
        ]);
    }
1253953
public function changepasswordAction()
    {
        // if the user isn't logged in, we can't change password
        if (!$this->zfcUserAuthentication()->hasIdentity()) {
            // redirect to the login redirect route
            return $this->redirect()->toRoute($this->getOptions()->getLoginRedirectRoute());
        }

        $form = $this->getChangePasswordForm();
        $prg = $this->prg(static::ROUTE_CHANGEPASSWD);

        $fm = $this->flashMessenger()->setNamespace('change-password')->getMessages();
        if (isset($fm[0])) {
            $status = $fm[0];
        } else {
            $status = null;
        }

        if ($prg instanceof Response) {
            return $prg;
        } elseif ($prg === false) {
            return array(
                'status' => $status,
                'changePasswordForm' => $form,
            );
        }

        $form->setData($prg);

        if (!$form->isValid()) {
            return array(
                'status' => false,
                'changePasswordForm' => $form,
            );
        }

        if (!$this->getUserService()->changePassword($form->getData())) {
            return array(
                'status' => false,
                'changePasswordForm' => $form,
            );
        }

        $this->flashMessenger()->setNamespace('change-password')->addMessage(true);
        return $this->redirect()->toRoute(static::ROUTE_CHANGEPASSWD);
    }
997566
public function getPassword(): ?PasswordBroker
    {
        if (!$this->hasPassword()) {
            $this->setPassword($this->getDefaultPassword());
        }
        return $this->password;
    }
309943
public function getPasswordResetToken()
    {
        if (empty($this->passwordResetTokenAttribute) || !is_string($this->passwordResetTokenAttribute)) {
            return null;
        }
        return $this->{$this->passwordResetTokenAttribute};
    }
453681
public function getPostReset()
    {
        $form       = new UserResetForm($this->di);
        $form->check();

        $views = [
            ["comment/user/pre/reset", ["form" => $form->getHTML()], "main"]
        ];

        $this->di->get("pageRenderComment")->renderPage([
            "views" => $views,
            "title" => "Reset password"
        ]);
    }
638080
public function getNewPasswordElement()
    {
        $element = $this->getElement($this->_newPasswordFieldName);

        if (! $element) {
            // Field new password
            $element = new \Zend_Form_Element_Password($this->_newPasswordFieldName);
            $element->setLabel($this->_('New password'));
            $element->setAttrib('size', 40);
            $element->setRequired(true);
            $element->setRenderPassword(true);
            $element->addValidator(new \Gems_User_Validate_NewPasswordValidator($this->user));

            $validator = new \MUtil_Validate_IsConfirmed($this->_newPasswordFieldName, $this->_('Repeat password'));
            $validator->setMessage(
                    $this->_("Must be the same as %fieldDescription%."),
                    \MUtil_Validate_IsConfirmed::NOT_SAME
                    );
            $element->addValidator($validator);

            $this->addElement($element);
        }

        return $element;
    }
201604
public function actionRequestPasswordReset()
    {
        $model = new PasswordResetRequestForm();
        if ($model->load(Yii::$app->getRequest()->post()) && $model->validate()) {
            if ($model->sendEmail()) {
                Yii::$app->getSession()
                    ->setFlash('success', yii::t('cms', 'Check your email for further instructions.'));

                return $this->goHome();
            } else {
                Yii::$app->getSession()
                    ->setFlash('error', 'Sorry, we are unable to reset password for email provided.');
            }
        }

        return $this->render('requestPasswordResetToken', [
            'model' => $model,
        ]);
    }
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,]);
        }
    }
401442
private function getPassword()
    {
        $password = $this->secret("Enter your password");
        $passwordAgain = $this->secret("Enter your password again");

        $validator = Validator::make([
            'password'              => $password,
            'password_confirmation' => $passwordAgain,
        ], [
            'password' => 'required|min:5|confirmed',
        ]);

        if( $validator->fails() ) {
            $this->info('');
            $this->error("The password must be at least 5 characters and must match!");
            $this->info('');

            return $this->getPassword();
        }

        $this->password = bcrypt($password);
    }
122608
protected function createModel()
    {
        $model = new ResetPasswordModel();
        $model->identityColumnName = $this->getLoginProvider()->getSettings()->identityColumnName;
        $model->resetPasswordEvent->attachHandler(function(){
            $this->initiateResetPassword();
        });

        return $model;
    }
182024
public function passwordForgot()
    {
        //Checks if reset password is enabled
        if (!getConfig('users.reset_password')) {
            $this->Flash->error(I18N_DISABLED);

            return $this->redirect(['_name' => 'homepage']);
        }

        $entity = $this->Users->newEntity($this->request->getData(), ['validate' => 'DoNotRequirePresence']);

        if ($this->request->is('post')) {
            //Checks for reCAPTCHA, if requested
            if (!getConfig('security.recaptcha') || $this->Recaptcha->verify()) {
                $user = $this->Users->findActiveByEmail($this->request->getData('email'))->first();

                if ($user) {
                    $token = $this->Token->create($user->email, ['type' => 'password_forgot', 'user_id' => $user->id]);
                    $this->getMailer('MeCms.User')
                        ->set('url', Router::url(['_name' => 'passwordReset', $user->id, $token], true))
                        ->send('passwordForgot', [$user]);
                    $this->Flash->success(__d('me_cms', 'We have sent you an email to reset your password'));

                    return $this->redirect(['_name' => 'login']);
                }

                if ($this->request->getData('email')) {
                    Log::error(sprintf(
                        '%s - Forgot password request with invalid email `%s`',
                        $this->request->clientIp(),
                        $this->request->getData('email')
                    ), 'users');
                }

                $this->Flash->error(__d('me_cms', 'No account found'));
            } else {
                $this->Flash->error(__d('me_cms', 'You must fill in the {0} control correctly', 'reCAPTCHA'));
            }
        }

        $this->set('user', $entity);
        $this->viewBuilder()->setLayout('login');
    }
923910
public function resendPassword()
    {
        $this->password = Password::generate(8);
        $this->save(false, ['password_hash']);

        return $this->mailer->sendGeneratedPassword($this, $this->password);
    }
147596
public function redirectToLostPassword()
    {
        $lostPasswordLink = Security::singleton()->Link('lostpassword');

        return $this->redirect($this->addBackURLParam($lostPasswordLink));
    }