Password resrt form

@author Aleh Hutnikau <hutnikau@1pt.com>
@return void
192962
public function resetPassword()
    {
        $this->defaultData();
        $token = $this->getRequestParameter('token');

        $formContainer = new tao_actions_form_ResetUserPassword();
        $form = $formContainer->getForm();

        $form->setValues(array('token'=>$token));

        $user = $this->getPasswordRecovery()->getUser(PasswordRecoveryService::PROPERTY_PASSWORD_RECOVERY_TOKEN, $token);
        if ($user === null) {
            $this->logInfo("Password recovery token not found. Token value: {$token}");
            $this->setData('header', __('User not found'));
            $this->setData('error', __('This password reset link is no longer valid. It may have already been used. If you still wish to reset your password please request a new link'));
            $this->setData('content-template', array('passwordRecovery/password-recovery-info.tpl', 'tao'));
        } else {
            if ($form->isSubmited() && $form->isValid()) {
                $this->getPasswordRecovery()->setPassword($user, $form->getValue('newpassword'));
                $this->logInfo("User {$user->getUri()} has changed the password.");
                $this->setData('info', __("Password successfully changed"));
                $this->setData('content-template', array('passwordRecovery/password-recovery-info.tpl', 'tao'));
            } else {
                $this->setData('form', $form->render());
                $this->setData('content-template', array('passwordRecovery/password-reset.tpl', 'tao'));
            }
        }

        $this->setView('layout.tpl', 'tao');
    }
799485
public function remindSend()
	{
		$credentials = array('email' => Input::get('email'));

		return Password::remind($credentials, function($message, $user)
		{
			$message->subject('Reset your password');
		});
	}
131267
public function password($password = null) {
		while (empty($password)) {
			$password = $this->in('Password');
		}

		$this->loadModel(CLASS_USERS);
		$this->Users->addBehavior('Tools.Passwordable', ['confirm' => false]);

		/** @var \App\Model\Entity\User $entity */
		$entity = $this->Users->newEntity([
			'pwd' => $password,
		], ['validate' => false]);
		/** @var \Tools\Model\Behavior\PasswordableBehavior $Passwordable */
		$Passwordable = $this->Users->behaviors()->get('Passwordable');
		$Passwordable->beforeSave(new Event('beforeSave'), $entity, new ArrayObject());

		$this->out('Generating hash...');
		$this->hr();
		$this->out($entity->password);
		$this->hr();
	}
61623
protected function createComponentPasswordForm(): Form
	{
		$form = $this->formFactory->create();
		$form->addProtection();

		$form->addText('username', 'cms.user.username')
			->setDisabled()
			->setDefaultValue($this->currentUser->username);

		if ($this->configurator->sendNewUserPassword) {
			$form->addCheckbox('generatePassword', 'cms.user.generatePassword')
				->addCondition($form::EQUAL, false)
				->toggle('password')
				->toggle('passwordVerify');
		} else {
			$form->addHidden('generatePassword', false);
		}

		$form->addPassword('password', 'cms.user.newPassword')
			->setOption('id', 'password')
			->addConditionOn($form['generatePassword'], Form::EQUAL, false)
			->setRequired()
			->addRule(Form::MIN_LENGTH, null, $this->minPasswordLength)
			->endCondition();
		$form->addPassword('passwordVerify', 'cms.user.passwordVerify')
			->setOption('id', 'passwordVerify')
			->addConditionOn($form['generatePassword'], Form::EQUAL, false)
			->setRequired()
			->addRule(Form::EQUAL, null, $form['password'])
			->endCondition();

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

		$form->onSuccess[] = [$this, 'passwordFormSucceeded'];
		return $form;
	}
308070
private function login()
    {
        if ($this->loggedIn) {
            return;
        }

        if (array_key_exists('rsakey', $this->sshConfig)) {
            $this->loginWithRsaKey();
        } elseif (array_key_exists('password', $this->sshConfig)) {
            $this->loginWithPassword();
        }

        $this->loggedIn = $this->validate();
    }
1039266
public function setPassword($password)
    {
        if (empty($password)) {
            $this->hashedPassword = null;
        } else {
            $this->hashedPassword = UsersManager::getPasswordHash($password);
        }
    }
470506
public function resetPassword()
    {
        if ($this->validate() && ($user = $this->getUser()) != null) {
            $user->resetPassword($this->password);
            return true;
        }
        return false;
    }
383300
public function editUserForgot()
    {
        $this->controlAccessUserForgot();

        $this->setUserForgot();
        $this->setTitleEditUserForgot();
        $this->setBreadcrumbEditUserForgot();

        $this->setData('forgetful_user', $this->data_user);
        $this->setData('password_limit', $this->user->getPasswordLength());

        $this->submitUserForgot();
        $this->outputEditUserForgot();
    }
167817
public function actionChangePassword()
    {
        $username = $this->prompt('Username:', ['required' => true]);
        $user = $this->findModel($username);
        $user->setPassword($this->prompt('New password:', [
            'required' => true,
            'pattern' => '#^.{6,255}$#i',
            'error' => 'More than 6 symbols',
        ]));
        $this->log($this->repository->save($user));
    }
1274931
public function resetPasswordAction() 
    {
        $pathAppConfigForm = '/meliscore/forms/meliscore_resetpass';
        $melisMelisCoreConfig = $this->serviceLocator->get('MelisCoreConfig');
        $appConfigForm = $melisMelisCoreConfig->getItem($pathAppConfigForm);
        $translator = $this->getServiceLocator()->get('translator');

        $rhash = $this->getHash();
        $melisLostPass = $this->getServiceLocator()->get('MelisCoreLostPassword');
        $hashExists = false;
        $textMessage = '';
        $success = 0;
        $login = '';
        $data = array();
        if($melisLostPass->hashExists($rhash)) {
            $hashExists = true;
            $data = $melisLostPass->getPasswordRequestData($rhash);
            foreach($data as $val) {
                $login = $val->rh_login;
            }
        }


        $factory = new \Zend\Form\Factory();
        $forgotForm = $factory->createForm($appConfigForm);
        
        $translator = $this->getServiceLocator()->get('translator');
        $this->getServiceLocator()->get('ViewHelperManager')->get('HeadTitle')->set($translator->translate('tr_meliscore_reset_password_header') . ' - ');
        
        $view = new ViewModel();
        if($this->getRequest()->isPost())
        {
            
            $password = $this->getRequest()->getPost('usr_pass');
            $confirmPass = $this->getRequest()->getPost('usr_pass_confirm');
            $passValidator = new \MelisCore\Validator\MelisPasswordValidator();
            
                if(strlen($password) >= 8) {
                    if(strlen($confirmPass) >= 8) {
                        //$passValidator = new \Zend\Validator\Regex(array('pattern' => '/^(?=.*?[0-9])(?=.*?[a-z])(?=.*?[A-Z])(?=.*?[^\w\s]).{8,}$/'));
                        $passValidator = new \MelisCore\Validator\MelisPasswordValidator();
                        if($passValidator->isValid($password))
                        {
                            // password and confirm password matching
                            if($password == $confirmPass)
                            {
                                $melisLostPass->processUpdatePassword($rhash, $password);
                                $textMessage = "tr_meliscore_user_password_change_succes";
                                $success = 1;
                                header( "location:/melis/login");
                            }
                            else
                            {
                                $success = 0;
                                $textMessage = 'tr_meliscore_tool_user_usr_password_not_match';
                            } // password and confirm password matching
                        }
                        else {
                                $success = 0;
                                $textMessage = 'tr_meliscore_tool_user_usr_password_regex_not_match';
                        } // password regex validator
                    }
                    else {
                        $success = 0;
                        $textMessage = 'tr_meliscore_tool_user_usr_confirm_password_error_low';
                    }// end confirm password length
                }
                else {
                    $success = 0;
                    $textMessage = 'tr_meliscore_tool_user_usr_password_error_low';
                }// end password length
        }
        
        
        $view->setVariable('meliscore_resetpass', $forgotForm);
        $view->setVariable('formFactory', $factory);
        $view->setVariable('formConfig', $appConfigForm);
        $view->hashExists = $hashExists;
        $view->message = $translator->translate($textMessage);
        $view->success = $success;
        $view->rhash =  $rhash;
        $this->layout()->schemes = $this->getSchemes();

        return $view;
    }
879525
public function main()
    {
        if (empty($this->args[0])) {
            $this->err('Please provide a password string.', 2);

            return false;
        }

        $hasher = new DefaultPasswordHasher;
        $passwordToHash = $this->args[0];
        $hashedPassword = $hasher->hash($passwordToHash);

        $this->out('Your password: ' . $hashedPassword, 2);

        return true;
    }
979810
public function changePassword()
    {
        $this->setPassword($this->password);
        $this->generateAuthKey();
        $this->removePasswordResetToken();
        return $this->save();
    }
1054612
public function resetPassword()
    {
        $user = $this->user;
        $user->setPassword($this->password);
        $user->removePasswordResetToken();

        return $user->save();
    }
3214
public function initForm()
    {
        $this->form = tao_helpers_form_FormFactory::getForm('passwordRecoveryForm');

        $connectElt = tao_helpers_form_FormFactory::getElement('recovery', 'Submit');
        $connectElt->setValue(__('Email'));
        $connectElt->setAttribute('class', 'btn-success small');
        $this->form->setActions(array($connectElt), 'bottom');
    }
913933
public function lostPassword()
    {
        if ($this->request->is('post') && !empty($this->request->data)) {
            /** @var User $user */
            $user = $this->Users->newEntity($this->request->data, ['validate' => 'emailOnly']);
            if (!$user->errors()) {
                if (($user = $this->Users->existsWithEmail($user->email))) {
                    $this->loadModel('Wasabi/Core.Tokens');

                    $this->Tokens->invalidateExistingTokens($user->id, TokensTable::TYPE_LOST_PASSWORD);
                    $token = $this->Tokens->generateToken($user, TokensTable::TYPE_LOST_PASSWORD);
                    $this->getMailer('Wasabi/Core.User')->send('lostPasswordEmail', [$user, $token]);
                }
                $this->Flash->success(__d('wasabi_core', 'We have sent you an email to reset your password.'));
                $this->redirect(['action' => 'login']);
                return;
            } else {
                $this->request->session()->write('data.lostPassword', $this->request->data());
                $this->Flash->error($this->formErrorMessage);
                $this->redirect(['action' => 'lostPassword']);
                return;
            }
        } else {
            if ($this->request->session()->check('data.lostPassword')) {
                $this->request->data = (array)$this->request->session()->read('data.lostPassword');
                $this->request->session()->delete('data.lostPassword');
            }
            $user = $this->Users->newEntity($this->request->data, ['validate' => 'emailOnly']);
        }
        $this->set('user', $user);
        $this->render(null, 'Wasabi/Core.support');
    }
1194920
public function index()
    {
        $this->authorize(PasswordResetsPolicy::PERMISSION_LIST);

        $resets = PasswordReset::with(['user'])
            ->orderBy('created_at', 'desc')
            ->paginate($this->perPage);

        $this->setTitle($title = trans('auth::password-resets.titles.password-resets-list'));
        $this->addBreadcrumb($title);

        return $this->view('admin.password-resets.index', compact('resets'));
    }
234600
protected function resetPasswordUser()
    {
        $result = $this->user_action->resetPassword($this->getSubmitted());
        $this->redirect($result['redirect'], $result['message'], $result['severity']);
    }