Updated error message is the code is not the right size or data type.

Updated two_factor to error is the user account is locked (locked = over 10 failed_login_count)
This commit is contained in:
Rebecca Law
2017-02-15 14:56:22 +00:00
parent 25227d89bd
commit cf3a933b1e
5 changed files with 26 additions and 18 deletions

View File

@@ -118,14 +118,7 @@ def sms_code():
return StringField('Text message code',
validators=[DataRequired(message='Cant be empty'),
Regexp(regex=verify_code,
message='Must be 5 digits')])
def email_code():
verify_code = '^\d{5}$'
return StringField("Email code",
validators=[DataRequired(message='Cant be empty'),
Regexp(regex=verify_code, message='Must be 5 digits')])
message='Code not found')])
class LoginForm(Form):

View File

@@ -1,12 +1,10 @@
from datetime import datetime, timedelta
from datetime import datetime
import dateutil
from flask import (
render_template,
url_for,
session,
jsonify,
current_app,
request,
abort
)
@@ -23,8 +21,6 @@ from app.utils import (
user_has_permissions,
get_current_financial_year,
FAILURE_STATUSES,
SENDING_STATUSES,
DELIVERED_STATUSES,
REQUESTED_STATUSES,
)

View File

@@ -32,6 +32,9 @@ def two_factor():
user.set_password(session['user_details']['password'])
user.reset_failed_login_count()
user_api_client.update_user(user)
if user.is_locked():
form.sms_code.errors.append('Code not found')
return render_template('views/two-factor.html', form=form)
activated_user = user_api_client.activate_user(user)
login_user(activated_user, remember=True)
finally: