Verify the password reset token, Prompt for new password, and set the user's password.
557727
def reset_password_view(self, token):
        
        # Verify token

        if self.call_or_get(current_user.is_authenticated):
            logout_user()

        data_items = self.token_manager.verify_token(
            token,
            self.USER_RESET_PASSWORD_EXPIRATION)

        user = None
        if data_items:
            # Get User by user ID
            user_id = data_items[0]
            user = self.db_manager.get_user_by_id(user_id)

            # Mark email as confirmed
            user_or_user_email_object = self.db_manager.get_primary_user_email_object(user)
            user_or_user_email_object.email_confirmed_at = datetime.utcnow()
            self.db_manager.save_object(user_or_user_email_object)
            self.db_manager.commit()

        if not user:
            flash(_('Your reset password token is invalid.'), 'error')
            return redirect(self._endpoint_url('user.login'))


        # Initialize form
        form = self.ResetPasswordFormClass(request.form)

        # Process valid POST
        if request.method == 'POST' and form.validate():
            # Change password
            password_hash = self.hash_password(form.new_password.data)
            user.password=password_hash
            self.db_manager.save_object(user)
            self.db_manager.commit()

            # Send 'password_changed' email
            if self.USER_ENABLE_EMAIL and self.USER_SEND_PASSWORD_CHANGED_EMAIL:
                self.email_manager.send_password_changed_email(user)

            # Send reset_password signal
            signals.user_reset_password.send(current_app._get_current_object(), user=user)

            # Flash a system message
            flash(_("Your password has been reset successfully."), 'success')

            # Auto-login after reset password or redirect to login page
            safe_next_url = self._get_safe_next_url('next', self.USER_AFTER_RESET_PASSWORD_ENDPOINT)
            if self.USER_AUTO_LOGIN_AFTER_RESET_PASSWORD:
                return self._do_login_user(user, safe_next_url)  # auto-login
            else:
                return redirect(url_for('user.login') + '?next=' + quote(safe_next_url))  # redirect to login page

        # Render form
        self.prepare_domain_translations()
        return render_template(self.USER_RESET_PASSWORD_TEMPLATE, form=form)
436612
def prompt_auth(self):
        """"""
        if self.username and self.password:
            return
        sys.stdout.write("Please insert your credentials for %s\n" % self.url.base_url)
        while not self.username:
            self.username = raw_input("Username [%s]: " % getpass.getuser())

        while not self.password:
            self.password = getpass.getpass("Password: ")
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)
1166751
def setCredentials(self, user, password):
        
        self._checkUserAndPass(user, password)
        self.user = user
        self.password = password
42940
def set_authorization_password(self, password):
        
        self.authorization_password = password
        self.changed_event.emit(self)
1371748
def check_token(self, respond):
        
        if respond.status_code == 401:
            self.credential.obtain_token(config=self.config)
            return False
        return True
579530
def login(self, user, passwd):
        ''''''
        resp = self.post('token', json={'username': user, 'password': passwd})
        self._token = resp.json()['response']['token']
637951
def change_password(self, user, password):
        
        if not self.__contains__(user):
            raise UserNotExists
        self.new_users[user] = self._encrypt_password(password) + "\n"
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();
    }
1095508
def send_reset_password_instructions(user):
    # type: (User) -> None
    
    token = generate_reset_password_token(user)
    url = url_for("login.reset_password", token=token)
    reset_link = request.url_root[:-1] + url

    subject = _("Password reset instruction for {site_name}").format(
        site_name=current_app.config.get("SITE_NAME")
    )
    mail_template = "password_reset_instructions"
    send_mail(subject, user.email, mail_template, user=user, reset_link=reset_link)
1033310
def change_password(self, previous, new_password):
        
        if not self.verify_password(previous):
            raise exceptions.Unauthorized('Incorrect password')

        if len(new_password) < options.min_length_password:
            msg = ('Passwords must be at least {} characters'
                   .format(options.min_length_password))
            raise exceptions.ValidationError(msg)

        if len(new_password) > options.max_length_password:
            msg = ('Passwords must be at no more than {} characters'
                   .format(options.max_length_password))
            raise exceptions.ValidationError(msg)

        self.password = self.hash_password(new_password)
        yield self._save()
1145439
def prompt_for_new_password():
    
    while True:
        passw = getpass.getpass()
        passw2 = getpass.getpass()
        if passw == passw2: return passw
        print 'Passwords do not match'
1150538
def reset_password(self, token=None, login_user=None):
        
        pwcol = self.options['password_column']
        if not token:
            if "token" in request.view_args:
                token = request.view_args["token"]
            elif "token" in request.values:
                token = request.values["token"]
            else:
                raise OptionMissingError(("Missing 'token' option or 'token' view arg "
                                          "or 'token' GET paramater in 'reset_password' action"))

        user = self.find_by_token(token, salt="password-reset", max_age=self.options["reset_password_ttl"])
        if user is None:
            if self.options["reset_password_error_message"]:
                flash(self.options["reset_password_error_message"], "error")
            current_context.exit(trigger_action_group="reset_password_failed")

        self.update_password_from_form(user)
        self.reset_password_signal.send(self, user=user)
        if (login_user is None and self.options["login_user_on_reset_password"]) or login_user:
            flask_login.login_user(user)
        return user
1132212
def after_model_change(self, form, User, is_created):
        """"""
        if is_created and form.notification.data is True:
            send_reset_password_instructions(User)
1070902
public function resetPassword($token)
  {
    if (isset($_SESSION['reset']) &&  $_SESSION['reset']['token'] == $token) {
      if (isset($_POST['resetPassword'])) {
        if ($_POST['password'] == '') {
          $this->errors[] = 'Input new password!';
        }
        if ($_POST['password'] != $_POST['password2']) {
          $this->errors[] = 'The passwords you entered do not match!';
        }
        if (strlen($_POST['password']) < 8) {
          $this->errors[] = 'The password must contain at least 8 characters!';
        }
        if (empty($this->errors)) {
          $changeData = R::findOne('users', 'email = ?', array($_SESSION['reset']['email']));
          $changeData->password = password_hash($_POST['password'], PASSWORD_DEFAULT);

          if (R::store($changeData)) {
            $loadAuthSession = R::findAll('authorization', 'user_id = ?', array($changeData['id']));

            foreach ($loadAuthSession as $load)
            {
              R::trash('authorization', $load['id']);
            }

            mail($_POST['email'], 'Reset Password', "Your password will be restored", 'BulveyzTeam');

            unset($_SESSION['reset']);
            redirect('/login');
          } else {
            exit('Error DataChange');
          }
        } else {
          echo "<div class='alert alert-danger' role='alert'>" . array_shift($this->errors) . "</div>";
        }
      }
    } else {
      exit('404');
    }
  }
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)
1136026
def refresh(self):
        """"""
        self._request_token(
            grant_type="password",
            username=self._username,
            password=self._password,
        )