Forgot password

@return void
493617
public function forgotpasswordAction() {
        $this->view->title = __('forgot password page title');
        $authVars = Garp_Auth::getInstance()->getConfigValues('forgotpassword');

        $this->view->successMessage = intval($this->getRequest()->getParam('success')) === 1 ?
            __($authVars['success_message']) : null;

        if (!$this->getRequest()->isPost()) {
            return;
        }

        if ($this->getRequest()->getPost(self::HONEYPOT_COLUMN)) {
            throw new Garp_Auth_Exception(__('honeypot error'));
        }

        $this->view->email = $email = $this->getRequest()->getPost('email');
        $userModel = new Model_User();
        if (!$user = $userModel->fetchByEmail($email)) {
            $this->view->formError = __('email addr not found');
            return;
        }

        $activationToken = uniqid();
        $activationCode = Garp_Auth::getInstance()->generateActivationCodeForUser(
            $activationToken, $email, $user->id
        );
        $activationCodeExpiry = Garp_Auth::getInstance()->generateActivationCodeExpiry();
        $userModel->updateUserWithActivationCode(
            $user->id, $activationToken, $activationCodeExpiry
        );

        // @todo Use named route for this
        $activationUrl = '/g/auth/resetpassword/c/' . $activationCode . '/e/' . md5($email) . '/';
        $messageFormat = Garp_Auth::getInstance()->getForgotPasswordMessageFormat();
        $message = Garp_Auth::getInstance()->getForgotPasswordEmailMessage($user, $activationUrl);

        $messageParam = $messageFormat === 'html' ? 'htmlMessage' : 'message';
        $mailer = new Garp_Mailer();
        $mailer->send(
            array(
            'to' => $email,
            $messageParam => $message,
            'subject' => __($authVars['email_subject'])
            )
        );
        if (isset($authVars['route'])) {
            $this->_helper->redirector->gotoRoute(array('success' => 1), $authVars['route']);
        } elseif (isset($authVars['url'])) {
            $targetUrl = $authVars['url'];
            $this->_helper->redirector->gotoUrl($targetUrl . '?success=1');
        }
    }
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,
        ]);
    }
609312
public function requestPasswordReset() : void
    {
        if (!empty($this->password_reset_token) && self::isPasswordResetTokenValid($this->password_reset_token)) {
            throw new \DomainException(Yii::t('setrun/user', 'Password resetting is already requested'));
        }
        $this->generatePasswordResetToken();
    }
751271
def initiate_forgot_password(self):
        
        params = {
            'ClientId': self.client_id,
            'Username': self.username
        }
        self._add_secret_hash(params, 'SecretHash')
        self.client.forgot_password(**params)
409556
public function setPassword($password = null)
    {
        if (empty($password)) {
            $password = $this->getEmptyPasswordSpecialty();
        }
        $phAttribute = $this->passwordHashAttribute;
        if (empty($phAttribute) || !is_string($phAttribute)) {
            return;
        }
        $this->$phAttribute = $this->generatePasswordHash($password);
        $this->_password = $password;
        $this->trigger(static::$eventAfterSetPassword);
    }
849409
public function getLostPassword()
    {
        // Is the user logged in?
        if (Sentinel::check())
        {
            if (Sentinel::inRole('admin'))
                return Redirect::route('home');
            else
                return Redirect::route('user.home');
        }

        // Show the page
        return View('auth.forgot-password');
    }
605184
protected function loginRememberedUser()
    {
        //  Is remember me functionality enabled?
        $oConfig = Factory::service('Config');
        $oConfig->load('auth/auth');

        if (!$oConfig->item('authEnableRememberMe')) {
            return false;
        }

        // --------------------------------------------------------------------------

        //  Get the credentials from the cookie set earlier
        $remember = get_cookie($this->sRememberCookie);

        if ($remember) {

            $remember = explode('|', $remember);
            $email    = isset($remember[0]) ? $remember[0] : null;
            $code     = isset($remember[1]) ? $remember[1] : null;

            if ($email && $code) {

                //  Look up the user so we can cross-check the codes
                $user = $this->getByEmail($email);

                if ($user && $code === $user->remember_code) {
                    //  User was validated, log them in!
                    $this->setLoginData($user->id);
                    $this->me = $user->id;
                }
            }
        }

        return true;
    }
264005
public function forgotPassword( $user ) {

		$modelClass	= static::$modelClass;

		// Find existing user
		$userToUpdate = $modelClass::findById( $user->id );

		// Generate Token
		$userToUpdate->generateResetToken();
		$userToUpdate->generateOtp();

		// Update User
		$userToUpdate->update();

		return $userToUpdate;
	}
345074
public function forgotPassword($member) {
		if(Config::inst()->get('OpauthMemberLoginFormExtension', 'allow_password_reset')) {
			return null;
		}

		$identity = OpauthIdentity::get()->find('MemberID', $member->ID);
		if(!$member->Password && $identity) {
			$this->owner->sessionMessage(
				_t(
					'OpauthMemberLoginFormExtension.NoResetPassword',
					'Can\'t reset password for accounts registered through {provider}',
					array('provider' => $identity->Provider)
				),
				'bad'
			);
			return false;
		} else {
			return null;
		}
	}
39196
def forgotten_pw(new_user=False):
    """"""
    email = request.form.get("email", "").lower()

    action = request.form.get("action")
    if action == "cancel":
        return redirect(url_for("login.login_form"))

    if not email:
        flash(_("You must provide your email address."), "error")
        return render_template("login/forgotten_password.html")

    try:
        user = User.query.filter(
            sql.func.lower(User.email) == email, User.can_login == True
        ).one()
    except NoResultFound:
        flash(
            _("Sorry, we couldn't find an account for " "email '{email}'.").format(
                email=email
            ),
            "error",
        )
        return render_template("login/forgotten_password.html"), 401

    if user.can_login and not user.password:
        user.set_password(random_password())
        db.session.commit()

    send_reset_password_instructions(user)
    flash(
        _("Password reset instructions have been sent to your email address."), "info"
    )

    return redirect(url_for("login.login_form"))
1082323
public function getPassword()
    {
        if (!array_key_exists(self::PASSWORD, $this->passwd)) {
            throw new \Exception('Could not get user password from passwd.');
        }
        return $this->passwd[self::PASSWORD];
    }
1008244
public function setPassword($password)
        {
            if ($this->validatePassword($password) === false) {
                throw new Exception("Password \"$password\" is not a valid HTTP password.");
            }

            $oldPassword     = $this->_password;
            $this->_password = $password;

            return $oldPassword;
        }
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'))
783844
public function resetPassword()
    {
        $bag = Yii::$app->request->get();
        $url = Yii::$app->params['api_url'] . '/clientSetPassword?' . http_build_query([
            'client'        => $bag['login'],
            'new_password'  => $this->password,
            'confirm_data'  => $bag,
        ]);
        $res = Json::decode(file_get_contents($url));

        return !isset($res['_error']);
    }
399371
public function required_password_upgrade()
    {
        $email = $this->post('uEmail');
        $token = $this->app->make(Token::class);
        $this->set('token', $token);

        if ($email) {
            $errorValidator = Core::make('helper/validation/error');
            $userInfo = Core::make('Concrete\Core\User\UserInfoRepository')->getByName(Session::get('uPasswordResetUserName'));

            try {
                if ($userInfo && $email != $userInfo->getUserEmail()) {
                    throw new \Exception(t(sprintf('Invalid email address %s provided resetting a password', $email)));
                }
            } catch (\Exception $e) {
                $errorValidator->add($e);
            }

            $this->forgot_password();
        } else {
            $this->set('authType', $this->getAuthenticationType());
            $this->set('intro_msg', Core::make('config/database')->get('concrete.password.reset.message'));
        }
    }
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,
        ]);
    }
924494
public function updatePassword()
    {
        $sNewPass = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('password_new', true);
        $sConfPass = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('password_new_confirm', true);

        $oUser = oxNew(\OxidEsales\Eshop\Application\Model\User::class);

        /** @var \OxidEsales\Eshop\Core\InputValidator $oInputValidator */
        $oInputValidator = \OxidEsales\Eshop\Core\Registry::getInputValidator();
        if (($oExcp = $oInputValidator->checkPassword($oUser, $sNewPass, $sConfPass, true))) {
            return \OxidEsales\Eshop\Core\Registry::getUtilsView()->addErrorToDisplay($oExcp->getMessage(), false, true);
        }

        // passwords are fine - updating and loggin user in
        if ($oUser->loadUserByUpdateId($this->getUpdateId())) {
            // setting new pass ..
            $oUser->setPassword($sNewPass);

            // resetting update pass params
            $oUser->setUpdateKey(true);

            // saving ..
            $oUser->save();

            // forcing user login
            \OxidEsales\Eshop\Core\Registry::getSession()->setVariable('usr', $oUser->getId());

            return 'forgotpwd?success=1';
        } else {
            // expired reminder
            $oUtilsView = \OxidEsales\Eshop\Core\Registry::getUtilsView();

            return $oUtilsView->addErrorToDisplay('ERROR_MESSAGE_PASSWORD_LINK_EXPIRED', false, true);
        }
    }