Fix bug with send_verify_code not including the to field.

This commit is contained in:
Nicholas Staples
2016-02-22 12:33:59 +00:00
parent b4ddcaa9b1
commit 980c01e10c
7 changed files with 11 additions and 11 deletions

View File

@@ -57,8 +57,8 @@ def request_password_reset(user):
user_api_client.update_user(user)
def send_verify_code(user_id, code_type, to=None):
return user_api_client.send_verify_code(user_id, code_type, to=to)
def send_verify_code(user_id, code_type, to):
return user_api_client.send_verify_code(user_id, code_type, to)
def check_verify_code(user_id, code, code_type):

View File

@@ -43,5 +43,5 @@ def verification_code_not_received():
def check_and_resend_verification_code():
# TODO there needs to be a way to generate a new session id
user = users_dao.get_user_by_email(session['user_details']['email'])
users_dao.send_verify_code(user.id, 'sms')
users_dao.send_verify_code(user.id, 'sms', user.mobile_number)
return redirect(url_for('main.two_factor'))

View File

@@ -21,7 +21,7 @@ def new_password(token):
form = NewPasswordForm()
if form.validate_on_submit():
users_dao.send_verify_code(user.id, 'sms')
users_dao.send_verify_code(user.id, 'sms', user.mobile_number)
session['user_details'] = {
'id': user.id,
'email': user.email_address,

View File

@@ -45,8 +45,8 @@ def register():
# How do we report to the user there is a problem with
# sending codes apart from service unavailable?
# at the moment i believe http 500 is fine.
users_dao.send_verify_code(user.id, 'sms')
users_dao.send_verify_code(user.id, 'email')
users_dao.send_verify_code(user.id, 'sms', user.mobile_number)
users_dao.send_verify_code(user.id, 'email', user.email_address)
session['expiry_date'] = str(datetime.now() + timedelta(hours=1))
session['user_details'] = {"email": user.email_address, "id": user.id}
return redirect(url_for('main.verify'))

View File

@@ -27,7 +27,7 @@ def sign_in():
if user.state == 'pending':
return redirect(url_for('.verify'))
elif user.is_active():
users_dao.send_verify_code(user.id, 'sms')
users_dao.send_verify_code(user.id, 'sms', user.mobile_number)
return redirect(url_for('.two_factor'))
# Vague error message for login in case of user not known, locked, inactive or password not verified
flash('Username or password is incorrect')

View File

@@ -74,7 +74,7 @@ def user_profile_email_authenticate():
if form.validate_on_submit():
session[NEW_EMAIL_PASSWORD_CONFIRMED] = True
send_verify_code(current_user.id, 'email', to=session[NEW_EMAIL])
send_verify_code(current_user.id, 'email', session[NEW_EMAIL])
return redirect(url_for('.user_profile_email_confirm'))
return render_template(
@@ -142,7 +142,7 @@ def user_profile_mobile_number_authenticate():
if form.validate_on_submit():
session[NEW_MOBILE_PASSWORD_CONFIRMED] = True
send_verify_code(current_user.id, 'sms', to=session[NEW_MOBILE])
send_verify_code(current_user.id, 'sms', session[NEW_MOBILE])
return redirect(url_for('.user_profile_mobile_number_confirm'))
return render_template(