mirror of
https://github.com/wassname/flask-security.git
synced 2026-06-28 16:20:24 +08:00
Add more test coverage
This commit is contained in:
+1
-15
@@ -237,9 +237,6 @@ class Security(object):
|
||||
|
||||
state = self._get_state(app, datastore or self.datastore)
|
||||
|
||||
if not hasattr(app, 'extensions'):
|
||||
app.extensions = {}
|
||||
|
||||
app.extensions['security'] = state
|
||||
|
||||
return state
|
||||
@@ -314,12 +311,8 @@ class AuthenticationProvider(object):
|
||||
|
||||
try:
|
||||
user = self._get_user(username_or_email)
|
||||
except AttributeError, e:
|
||||
self.auth_error("Could not find user datastore: %s" % e)
|
||||
except exceptions.UserNotFoundError, e:
|
||||
except exceptions.UserNotFoundError:
|
||||
raise exceptions.BadCredentialsError("Specified user does not exist")
|
||||
except Exception, e:
|
||||
self.auth_error('Unexpected authentication error: %s' % e)
|
||||
|
||||
if requires_confirmation(user):
|
||||
raise exceptions.BadCredentialsError('Account requires confirmation')
|
||||
@@ -332,10 +325,3 @@ class AuthenticationProvider(object):
|
||||
|
||||
# bad match
|
||||
raise exceptions.BadCredentialsError("Password does not match")
|
||||
|
||||
def auth_error(self, msg):
|
||||
"""Sends an error log message and raises an authentication error.
|
||||
|
||||
:param msg: An authentication error message"""
|
||||
current_app.logger.error(msg)
|
||||
raise exceptions.AuthenticationError(msg)
|
||||
|
||||
@@ -132,10 +132,10 @@ def register_user():
|
||||
|
||||
|
||||
def send_confirmation():
|
||||
form = ResendConfirmationForm()
|
||||
form = ResendConfirmationForm(csrf_enabled=not app.testing)
|
||||
|
||||
if form.validate_on_submit():
|
||||
user = _datastore.find_user(email=form.email.data)
|
||||
user = _datastore.find_user(**form.to_dict())
|
||||
|
||||
reset_confirmation_token(user)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user