mirror of
https://github.com/wassname/flask-security.git
synced 2026-07-28 11:20:10 +08:00
Fix up forms to grab values in certain cases
This commit is contained in:
@@ -342,7 +342,7 @@ class AuthenticationProvider(object):
|
||||
raise exceptions.BadCredentialsError('Specified user does not exist.')
|
||||
|
||||
if requires_confirmation(user):
|
||||
raise exceptions.ConfirmationError('Email requires confirmation.')
|
||||
raise exceptions.ConfirmationError('Email requires confirmation.', user)
|
||||
|
||||
# compare passwords
|
||||
if verify_password(password, user.password,
|
||||
|
||||
@@ -51,11 +51,16 @@ class PasswordConfirmFormMixin():
|
||||
validators=[EqualTo('password', message="Passwords do not match")])
|
||||
|
||||
|
||||
class ResendConfirmationForm(Form, UserEmailFormMixin):
|
||||
class SendConfirmationForm(Form, UserEmailFormMixin):
|
||||
"""The default forgot password form"""
|
||||
|
||||
submit = SubmitField("Resend Confirmation Instructions")
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(SendConfirmationForm, self).__init__(*args, **kwargs)
|
||||
if request.method == 'GET':
|
||||
self.email.data = request.args.get('email', None)
|
||||
|
||||
def to_dict(self):
|
||||
return dict(email=self.email.data)
|
||||
|
||||
@@ -77,7 +82,8 @@ class PasswordlessLoginForm(Form, EmailFormMixin):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(PasswordlessLoginForm, self).__init__(*args, **kwargs)
|
||||
self.next.data = request.args.get('next', None)
|
||||
if request.method == 'GET':
|
||||
self.next.data = request.args.get('next', None)
|
||||
|
||||
def to_dict(self):
|
||||
return dict(email=self.email.data)
|
||||
|
||||
@@ -15,12 +15,11 @@ from werkzeug.datastructures import MultiDict
|
||||
from werkzeug.local import LocalProxy
|
||||
|
||||
from flask_security.confirmable import confirm_by_token, reset_confirmation_token
|
||||
from flask_security.core import current_user
|
||||
from flask_security.decorators import login_required
|
||||
from flask_security.exceptions import ConfirmationError, BadCredentialsError, \
|
||||
ResetPasswordError, PasswordlessLoginError
|
||||
from flask_security.forms import LoginForm, RegisterForm, ForgotPasswordForm, \
|
||||
ResetPasswordForm, ResendConfirmationForm, PasswordlessLoginForm
|
||||
ResetPasswordForm, SendConfirmationForm, PasswordlessLoginForm
|
||||
from flask_security.passwordless import send_login_instructions, login_by_token
|
||||
from flask_security.recoverable import reset_by_token, \
|
||||
reset_password_reset_token
|
||||
@@ -84,7 +83,7 @@ def authenticate():
|
||||
|
||||
except ConfirmationError, e:
|
||||
msg = str(e)
|
||||
confirm_url = url_for_security('send_confirmation')
|
||||
confirm_url = url_for_security('send_confirmation', email=e.user.email)
|
||||
|
||||
except BadCredentialsError, e:
|
||||
msg = str(e)
|
||||
@@ -189,7 +188,7 @@ def token_login(token):
|
||||
def send_confirmation():
|
||||
"""View function which sends confirmation instructions."""
|
||||
|
||||
form = ResendConfirmationForm(csrf_enabled=not app.testing)
|
||||
form = SendConfirmationForm(csrf_enabled=not app.testing)
|
||||
|
||||
if form.validate_on_submit():
|
||||
user = _datastore.find_user(**form.to_dict())
|
||||
|
||||
Reference in New Issue
Block a user