コード例 #1
0
ファイル: auth_service.py プロジェクト: NiHighlism/Minerva
    def reset_password_with_token(token):
        """
        Take in password reset form from the user and change password.

        :param token: validation token
        :type token: str
        """
        try:
            email = confirm_reset_token(token)
        except BaseException:
            LOG.info('The password reset link has expired or is invalid')
            response_object = {
                'status': 'Fail',
                'message': 'Password Reset link is invalid or has expired',
            }
            return response_object, 400

        form = PasswordForm()
        if form.validate_on_submit():
            user = User.query.filter_by(email=email).first()
            user.resetPassword(form.password.data)
            response_object = {
                'status': 'Success',
                'message': 'Password has been reset successfully',
            }
            return response_object, 200

        return redirect(url_for('api.auth_reset_token_verify'), token=token)
コード例 #2
0
 def confirm_reset_token_service(token):
     try:
         email = confirm_reset_token(token)
     except BaseException:
         LOG.info('The password reset link has expired or is invalid')
         response_object = {
             'status': 'Fail',
             'message': 'Password Reset link is invalid or has expired',
         }
         return response_object, 400
     form = PasswordForm()
     headers = {'Content-Type': 'text/html'}
     return make_response(
         render_template('reset_password.html', form=form, token=token),
         200, headers)