From ac674ecd86765c5bbab2606b29ae49c4a5d81f90 Mon Sep 17 00:00:00 2001 From: Matt Wright Date: Wed, 15 Aug 2012 19:33:23 -0400 Subject: [PATCH] Fix some messaging --- flask_security/core.py | 23 ++++++++++++----------- flask_security/views.py | 5 ++++- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/flask_security/core.py b/flask_security/core.py index f94bbd4..6a0d428 100644 --- a/flask_security/core.py +++ b/flask_security/core.py @@ -47,6 +47,7 @@ _default_config = { 'RESET_PASSWORD_ERROR_VIEW': '/', 'POST_REGISTER_VIEW': None, 'POST_CONFIRM_VIEW': None, + 'POST_RESET_VIEW': None, 'UNAUTHORIZED_VIEW': None, 'DEFAULT_ROLES': [], 'CONFIRMABLE': False, @@ -73,20 +74,20 @@ _default_config = { _default_messages = { 'UNAUTHORIZED': ('You do not have permission to view this resource.', 'error'), 'EMAIL_CONFIRMED': ('Your email has been confirmed. You may now log in.', 'success'), - 'ALREADY_CONFIRMED': ('Your email has already been confirmed', 'info'), - 'INVALID_CONFIRMATION_TOKEN': ('Invalid confirmation token', 'error'), + 'ALREADY_CONFIRMED': ('Your email has already been confirmed.', 'info'), + 'INVALID_CONFIRMATION_TOKEN': ('Invalid confirmation token.', 'error'), 'PASSWORD_RESET_REQUEST': ('Instructions to reset your password have been sent to %(email)s.', 'info'), 'PASSWORD_RESET_EXPIRED': ('You did not reset your password within %(within)s. New instructions have been sent to %(email)s.', 'error'), - 'INVALID_RESET_PASSWORD_TOKEN': ('Invalid reset password token', 'error'), - 'CONFIRMATION_REQUIRED': ('Email requires confirmation', 'error'), + 'INVALID_RESET_PASSWORD_TOKEN': ('Invalid reset password token.', 'error'), + 'CONFIRMATION_REQUIRED': ('Email requires confirmation.', 'error'), 'CONFIRMATION_REQUEST': ('A new confirmation code has been sent to %(email)s.', 'info'), 'CONFIRMATION_EXPIRED': ('You did not confirm your email within %(within)s. New instructions to confirm your email have been sent to %(email)s.', 'error'), 'LOGIN_EXPIRED': ('You did not login within %(within)s. New instructions to login to your account have been sent to %(email)s.', 'error'), - 'LOGIN_EMAIL_SENT': ('Instructions to log in to your account have been sent to %(email)s', 'success'), - 'INVALID_LOGIN_TOKEN': ('Invalid login token', 'error'), - 'DISABLED_ACCOUNT': ('Account is disabled', 'error'), - 'PASSWORDLESS_LOGIN_SUCCESSFUL': ('You have successfuly logged in', 'success'), - 'PASSWORD_RESET': ('Your password has successfully been reset. You may now log in.', 'success') + 'LOGIN_EMAIL_SENT': ('Instructions to log in to your account have been sent to %(email)s.', 'success'), + 'INVALID_LOGIN_TOKEN': ('Invalid login token.', 'error'), + 'DISABLED_ACCOUNT': ('Account is disabled.', 'error'), + 'PASSWORDLESS_LOGIN_SUCCESSFUL': ('You have successfuly logged in.', 'success'), + 'PASSWORD_RESET': ('You successfully reset your password and you have been logged in automatically.', 'success') } @@ -330,10 +331,10 @@ class AuthenticationProvider(object): try: user = self._get_user(username_or_email) except exceptions.UserNotFoundError: - raise exceptions.BadCredentialsError('Specified user does not exist') + raise exceptions.BadCredentialsError('Specified user does not exist.') if requires_confirmation(user): - raise exceptions.BadCredentialsError('Email requires confirmation') + raise exceptions.BadCredentialsError('Email requires confirmation.') # compare passwords if verify_password(password, user.password, diff --git a/flask_security/views.py b/flask_security/views.py index 6083af1..ee3b66d 100644 --- a/flask_security/views.py +++ b/flask_security/views.py @@ -248,7 +248,10 @@ def reset_password(token): do_flash(*get_message('PASSWORD_RESET')) - return redirect(_security.login_manager.login_view) + login_user(user) + + return redirect(_security.post_reset_view or + _security.post_login_view) except ResetPasswordError, e: msg, cat = str(e), 'error'