Fix flash messages and fix password reset

This commit is contained in:
Matt Wright
2012-08-15 19:22:24 -04:00
parent 1b505d0f39
commit bb91c4a81a
2 changed files with 11 additions and 8 deletions
+2 -1
View File
@@ -85,7 +85,8 @@ _default_messages = {
'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')
'PASSWORDLESS_LOGIN_SUCCESSFUL': ('You have successfuly logged in', 'success'),
'PASSWORD_RESET': ('Your password has successfully been reset. You may now log in.', 'success')
}
+9 -7
View File
@@ -139,9 +139,9 @@ def send_login():
if user.is_active():
send_login_instructions(user, form.next.data)
do_flash(get_message('LOGIN_EMAIL_SENT', email=user.email))
do_flash(*get_message('LOGIN_EMAIL_SENT', email=user.email))
else:
do_flash(get_message('DISABLED_ACCOUNT'))
do_flash(*get_message('DISABLED_ACCOUNT'))
return render_template('security/logins/passwordless.html', login_form=form)
@@ -163,7 +163,7 @@ def token_login(token):
return redirect(request.referrer or _security.login_manager.login_view)
do_flash(get_message('PASSWORDLESS_LOGIN_SUCCESSFUL'))
do_flash(*get_message('PASSWORDLESS_LOGIN_SUCCESSFUL'))
return redirect(next or _security.post_login_view)
@@ -204,7 +204,7 @@ def confirm_email(token):
return redirect(get_url(_security.confirm_error_view))
do_flash(get_message('EMAIL_CONFIRMED'))
do_flash(*get_message('EMAIL_CONFIRMED'))
return redirect(_security.post_confirm_view or _security.post_login_view)
@@ -228,9 +228,6 @@ def forgot_password():
return redirect(_security.post_forgot_view)
else:
_logger.debug('A reset password request was made for %s but '
'that email does not exist.' % form.email.data)
for key, value in form.errors.items():
do_flash(value[0], 'error')
@@ -246,8 +243,13 @@ def reset_password(token):
if form.validate_on_submit():
try:
user = reset_by_token(token=token, **form.to_dict())
_logger.debug('%s reset their password' % user)
do_flash(*get_message('PASSWORD_RESET'))
return redirect(_security.login_manager.login_view)
except ResetPasswordError, e:
msg, cat = str(e), 'error'