Request password reset.

@access public
@since 2.0.0
483814
public function PasswordRequest() {
      Gdn::Locale()->SetTranslation('Email', T(UserModel::SigninLabelCode()));
      if ($this->Form->IsPostBack() === TRUE) {
         $this->Form->ValidateRule('Email', 'ValidateRequired');

         if ($this->Form->ErrorCount() == 0) {
            try {
               $Email = $this->Form->GetFormValue('Email');
               if (!$this->UserModel->PasswordRequest($Email)) {
                  $this->Form->SetValidationResults($this->UserModel->ValidationResults());
               }
            } catch (Exception $ex) {
               $this->Form->AddError($ex->getMessage());
            }
            if ($this->Form->ErrorCount() == 0) {
               $this->Form->AddError('Success!');
               $this->View = 'passwordrequestsent';
            }
         } else {
            if ($this->Form->ErrorCount() == 0)
               $this->Form->AddError("Couldn't find an account associated with that email/username.");
         }
      }
      $this->Render();
   }
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,
        ]);
    }
1032324
public function resetPassword(Request $request)
    {
        // check if user has permissions to access this link
        if(!User::hasAccess('user', 'update')) {
            return $this->noPermission();
        }
        // validation
        $validator = Validator::make(
            $request->all(), [
            'password' => 'required|same:confpassword',
            'id' => 'required',
            ]
        );

        // if validation fails return json response
        if ($validator->fails()) {
            return $this->response("Please check all required fields!", 400, null, false, false, true, $validator->errors());
        }

        $user = User::where('userID', $request->id)->update(
            [
            'password' => $password = Hash::make($request->password)
            ]
        );

        if ($user) {
            $result = $this->response('Password is updated');
        }else{
            $result = $this->response('Internal server error. Please try again later', 500);
        }
        return $result;
    }
1340630
def reset_password
    email = params[:session] && params[:session][:email]
    credential = Credentials::Email.with email

    if user = (credential && credential.user)
      token = Tokens::PasswordReset.random_for user
      email = ::SessionMailer.reset_password_email(email, token, root_url)
      # TODO(pwnall): fix the serialization errors blocking deliver_later
      email.deliver_now
    end

    respond_to do |format|
      if user
        format.html do
          redirect_to new_session_url, alert:
              'Please check your e-mail for instructions'
        end
        format.json { render json: { } }
      else
        error_text = 'Invalid e-mail'
        format.html do
          redirect_to new_session_url, alert: error_text
        end
        format.json do
          render json: { error: :not_found, text: notice }
        end
      end
    end
  end
861900
public function resetPassword()
    {
        $user = $this->_user;
        $user->password = $this->password;
        $user->removePasswordResetToken();

        return $user->save();
    }
750301
def reset_passwd(self, data):
        
        error = False
        msg = ""

        # Check input format
        if len(data["passwd"]) < 6:
            error = True
            msg = _("Password too short.")
        elif data["passwd"] != data["passwd2"]:
            error = True
            msg = _("Passwords don't match !")

        if not error:
            passwd_hash = hashlib.sha512(data["passwd"].encode("utf-8")).hexdigest()
            user = self.database.users.find_one_and_update({"reset": data["reset_hash"]},
                                                           {"$set": {"password": passwd_hash},
                                                            "$unset": {"reset": True, "activate": True}})
            if user is None:
                error = True
                msg = _("Invalid reset hash.")
            else:
                msg = _("Your password has been successfully changed.")

        return msg, error
844389
public function onResetPassword()
    {
        $rules = [
            'code'     => 'required',
            'password' => 'required|between:4,255'
        ];

        $validation = Validator::make(post(), $rules);
        if ($validation->fails()) {
            throw new ValidationException($validation);
        }

        $errorFields = ['code' => Lang::get(/*Invalid activation code supplied.*/'rainlab.user::lang.account.invalid_activation_code')];

        /*
         * Break up the code parts
         */
        $parts = explode('!', post('code'));
        if (count($parts) != 2) {
            throw new ValidationException($errorFields);
        }

        list($userId, $code) = $parts;

        if (!strlen(trim($userId)) || !strlen(trim($code)) || !$code) {
            throw new ValidationException($errorFields);
        }

        if (!$user = Auth::findUserById($userId)) {
            throw new ValidationException($errorFields);
        }

        if (!$user->attemptResetPassword($code, post('password'))) {
            throw new ValidationException($errorFields);
        }
    }
436329
public function resetPassword()
    {
        $user = $this->_user;
        $user->setPassword($this->password);
        $user->removePasswordResetToken();
        Event::off(BaseActiveRecord::className(), BaseActiveRecord::EVENT_AFTER_UPDATE);

        return $user->save(false);
    }
177757
private function resetPasswordEncryption()
    {
        $defaultEncryption = Security::config()->get('password_encryption_algorithm');
        if ($this->owner->PasswordEncryption != $defaultEncryption) {
            DB::prepared_query(
                'UPDATE "Member" SET "PasswordEncryption" = ? WHERE ID = ?',
                [$defaultEncryption, $this->owner->ID]
            );
        }
    }
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');
    }
259447
protected function ResetPasswordConfirm()
	{
		$myWords = $this->WordCollection();

		if (!$this->_login->getCanRetrievePassword())
		{
			$this->FormLogin();
			return;
		}
		elseif ($this->_login->getPassword() == "" || $this->_context->get('password2') == "")
		{
			$container = new XmlnukeUIAlert($this->_context, UIAlert::BoxAlert);
			$container->setAutoHide(5000);
			$container->addXmlnukeObject(new XmlnukeText($myWords->Value("PASSWORDISREQUIRED"), true));
			$this->_blockCenter->addXmlnukeObject($container);

			$this->ResetPassword();
			return;
		}
		elseif ($this->_login->getPassword() != $this->_context->get('password2'))
		{
			$container = new XmlnukeUIAlert($this->_context, UIAlert::BoxAlert);
			$container->setAutoHide(5000);
			$container->addXmlnukeObject(new XmlnukeText($myWords->Value("PASSWORDNOTMATCH"), true));
			$this->_blockCenter->addXmlnukeObject($container);

			$this->ResetPassword();
			return;
		}

		$user = $this->_users->getUserName( $this->_login->getUsername() );

		$tokenValid = $user->getField("TOKEN_PWD_RESET") == $this->_login->getResetToken()
				&& $user->getField("TOKEN_PWD_RESET_VALID") >= DateUtil::Today(DATEFORMAT::YMD);

		if (is_null($user) || !$tokenValid)
		{
			$this->FormLogin();
		}
		elseif ($user->getField("TOKEN_PWD_RESET") != $this->_login->getResetToken())
		{
			$container = new XmlnukeUIAlert($this->_context, UIAlert::BoxAlert);
			$container->setAutoHide(5000);
			$container->addXmlnukeObject(new XmlnukeText($myWords->Value("RESETINVALIDTOKEN"), true));
			$this->_blockCenter->addXmlnukeObject($container);

			$this->FormLogin();
			return;
		}
		else
		{
			$newpassword = $this->_users->getSHAPassword($this->_login->getPassword());
			$user->setField('TOKEN_PWD_RESET', '');
			$user->setField('TOKEN_PWD_RESET_VALID', '');
			$user->setField($this->_users->getUserTable()->password, $newpassword);
			$this->_users->Save();
			$container = new XmlnukeUIAlert($this->_context, UIAlert::ModalDialog, "");
			$container->addRedirectButton($myWords->Value("TXT_BACK"), $this->_login->getReturnUrl());
			$container->addXmlnukeObject(new XmlnukeText($myWords->Value("RESETPASSWORDOK"), true));
			$this->_blockCenter->addXmlnukeObject($container);
			$this->FormLogin();
		}
	}
649287
def request_password_reset(self, user, base_url):
        
        user.generate_password_link()
        db.session.add(user)
        db.session.commit()
        events.password_change_requested_event.send(user)
        self.send_password_change_message(user, base_url)
373021
def forgot_password():
    """"""

    form_class = _security.forgot_password_form

    if request.is_json:
        form = form_class(MultiDict(request.get_json()))
    else:
        form = form_class()

    if form.validate_on_submit():
        send_reset_password_instructions(form.user)
        if not request.is_json:
            do_flash(*get_message('PASSWORD_RESET_REQUEST',
                     email=form.user.email))

    if request.is_json:
        return _render_json(form, include_user=False)

    return _security.render_template(config_value('FORGOT_PASSWORD_TEMPLATE'),
                                     forgot_password_form=form,
                                     **_ctx('forgot_password'))
570070
public function changePassword() {
    $this->requireTransaction();
    $session = $this->getSession();
    $permissionManager = $this->getPermissionManager();
    $request = $this->getRequest();
    $response = $this->getResponse();

    // load model
    $authUser = $this->principalFactory->getUser($session->getAuthUser());
    if ($authUser) {
      // add permissions for this operation
      $oidStr = $authUser->getOID()->__toString();
      $this->tempPermissions[] = $permissionManager->addTempPermission($oidStr, '', PersistenceAction::READ);
      $this->tempPermissions[] = $permissionManager->addTempPermission($oidStr.'.password', '', PersistenceAction::UPDATE);

      $this->changePasswordImpl($authUser, $request->getValue('oldpassword'),
          $request->getValue('newpassword1'), $request->getValue('newpassword2'));
    }
    // success
    $response->setAction('ok');
  }
1187694
@PostMapping(
      value = "/password/reset",
      headers = "Content-Type=application/x-www-form-urlencoded")
  @ResponseStatus(HttpStatus.NO_CONTENT)
  public void resetPassword(@Valid @ModelAttribute PasswordResetRequest passwordResetRequest) {
    accountService.resetPassword(passwordResetRequest.getEmail());
  }
84726
public function resetPassword(Request $request): Response
    {
        $this->denyAccessUnlessLoggedIn();

        // @todo verify hash and if not valid show error page with message

        if ($request->isMethod(Request::METHOD_POST)) {
            // @todo: update password, login customer and redirect to account and show success message
            return $this->redirectToRoute('frontend.account.home.page', []);
        }

        return $this->renderStorefront('@Storefront/page/account/password-reset/password-reset.html.twig', ['page' => []]);
    }
1123387
public function toMail()
    {
        return (new MailMessage())
            ->line('You are receiving this email because we received a password reset request for your account.')
            ->action('Reset Password', url(config('app.url').route('platform.password.reset', $this->token, false)))
            ->line('If you did not request a password reset, no further action is required.');
    }