Testing utility for capturing password reset requests.

    :param reset_password_sent_at: An optional datetime object to set the
                                   user's `reset_password_sent_at` to
162033
def capture_reset_password_requests(reset_password_sent_at=None):
    
    reset_requests = []

    def _on(app, **data):
        reset_requests.append(data)

    reset_password_instructions_sent.connect(_on)

    try:
        yield reset_requests
    finally:
        reset_password_instructions_sent.disconnect(_on)
677145
def _password(self, password):
        
        with self.lock:
            self.send('PASS :%s' % password, error_check=True)
1248690
def request_reset(self, event):
        """"""

        self.log('Password reset request received:', event.__dict__, lvl=hilight)

        user_object = objectmodels['user']

        email = event.data.get('email', None)
        email_user = None

        if email is not None and user_object.count({'mail': email}) > 0:
            email_user = user_object.find_one({'mail': email})

        if email_user is None:
            self._fail(event, msg="Mail address unknown")
            return
1024345
def generate_reset_password_token(self, user):
        
        password_hash = self.hash_data(user.password) if user.password else None
        data = [str(user.id), password_hash]
        return self.security.reset_serializer.dumps(data)
977386
def change_password(self, new_password):
        
        self.set_password(new_password)
        self.save()
        password_changed.send(sender=self.__class__, user=self)
1171103
def create_reset_digest
      self.reset_token = Lines::User.generate_token
      update_attribute(:reset_digest,  Lines::User.digest(reset_token))
      update_attribute(:reset_sent_at, Time.zone.now)
    end
203003
function onSendPasswordResetEmail() {
  var email = $('#password-reset-email').val();
  auth.sendPasswordResetEmail(email, getActionCodeSettings()).then(function() {
    alertSuccess('Email sent!');
  }, onAuthError);
}
1105857
def resetPassword(self, userId):
    '''
    
    '''
    self._setHeaders('resetPassword')
    return self._sforce.service.resetPassword(userId)
771482
public function requestReset()
  {
    if (isset($_POST['requestReset'])) {
      if ($_POST['email'] == '') {
        $this->errors[] = 'Input Email!';
      }
      if (!R::count('users', 'email = ?', array($_POST['email']))) {
        $this->errors[] = 'This account not found!';
      }
      if (empty($this->errors)) {
        $_SESSION['reset'] = [
            'token' => token(),
            'email' => $_POST['email']
        ];

        $link = siteURL()."restore/".$_SESSION['reset']['token'];
        Mailer::smtpStart();
        Mailer::$mail->addAddress($_POST['email']);    
        Mailer::$mail->isHTML(true);
        Mailer::$mail->Subject = 'Password recovery';
        Mailer::$mail->Body = "<a href='{$link}'>Password recovery link</a>";
        Mailer::$mail->setFrom(getenv('SMTP_USER_NAME'), 'Password recovery');
        Mailer::$mail->send();

        echo "<div class='alert alert-success' role='alert'>A password recovery link has been sent to the email</div>";
      } else {
        echo "<div class='alert alert-danger' role='alert'>" . array_shift($this->errors) . "</div>";
      }
    }
  }
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,
        ]);
    }
695259
def settings_system_reset(self):
        
        data = {
            "auth_password": self._password
        }

        response = self._delete(url.settings_system, body=data)
        self._check_response(response, 204)
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'))
1219253
def reset_password(self):
        '''
        
        '''
        post_data = self.get_post_data()

        if 'email' in post_data:
            userinfo = MUser.get_by_email(post_data['email'])

            if tools.timestamp() - userinfo.time_reset_passwd < 70:
                self.set_status(400)
                kwd = {
                    'info': '两次重置密码时间应该大于1分钟',
                    'link': '/user/reset-password',
                }
                self.render('misc/html/404.html', kwd=kwd, userinfo=self.userinfo)
                return False

            if userinfo:
                timestamp = tools.timestamp()
                passwd = userinfo.user_pass
                username = userinfo.user_name
                hash_str = tools.md5(username + str(timestamp) + passwd)
                url_reset = '{0}/user/reset-passwd?u={1}&t={2}&p={3}'.format(
                    config.SITE_CFG['site_url'],
                    username,
                    timestamp,
                    hash_str)
                email_cnt = '''<div>请查看下面的信息，并<span style="color:red">谨慎操作</span>：</div>
            <div>您在"{0}"网站（{1}）申请了密码重置，如果确定要进行密码重置，请打开下面链接：</div>
            <div><a href={2}>{2}</a></div>
            <div>如果无法确定本信息的有效性，请忽略本邮件。</div>'''.format(config.SMTP_CFG['name'],
                                                       config.SITE_CFG['site_url'],
                                                       url_reset)

                if send_mail([userinfo.user_email], "{0}|密码重置".format(config.SMTP_CFG['name']),
                             email_cnt):
                    MUser.update_time_reset_passwd(username, timestamp)
                    self.set_status(200)
                    logger.info('password has been reset.')
                    return True

                self.set_status(400)
                return False
            self.set_status(400)
            return False
        self.set_status(400)
        return False
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.');
    }
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,
        ]);
    }
1321488
def request_password_reset(self, user_id):
		""""""
		content = self._fetch("/user/%s/password/request_reset" % (user_id), method="POST")
		return FastlyUser(self, content)
1084166
def send_password_changed_notice(user):
    
    if config_value('SEND_PASSWORD_CHANGE_EMAIL'):
        subject = config_value('EMAIL_SUBJECT_PASSWORD_CHANGE_NOTICE')
        _security.send_mail(subject, user.email, 'change_notice', user=user)