mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-07 07:48:26 -04:00
Merge pull request #188 from alphagov/send_verify_code_fix
Fix bug with send_verify_code not including the to field.
This commit is contained in:
@@ -57,8 +57,8 @@ def request_password_reset(user):
|
|||||||
user_api_client.update_user(user)
|
user_api_client.update_user(user)
|
||||||
|
|
||||||
|
|
||||||
def send_verify_code(user_id, code_type, to=None):
|
def send_verify_code(user_id, code_type, to):
|
||||||
return user_api_client.send_verify_code(user_id, code_type, to=to)
|
return user_api_client.send_verify_code(user_id, code_type, to)
|
||||||
|
|
||||||
|
|
||||||
def check_verify_code(user_id, code, code_type):
|
def check_verify_code(user_id, code, code_type):
|
||||||
|
|||||||
@@ -43,5 +43,5 @@ def verification_code_not_received():
|
|||||||
def check_and_resend_verification_code():
|
def check_and_resend_verification_code():
|
||||||
# TODO there needs to be a way to generate a new session id
|
# TODO there needs to be a way to generate a new session id
|
||||||
user = users_dao.get_user_by_email(session['user_details']['email'])
|
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'))
|
return redirect(url_for('main.two_factor'))
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ def new_password(token):
|
|||||||
form = NewPasswordForm()
|
form = NewPasswordForm()
|
||||||
|
|
||||||
if form.validate_on_submit():
|
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'] = {
|
session['user_details'] = {
|
||||||
'id': user.id,
|
'id': user.id,
|
||||||
'email': user.email_address,
|
'email': user.email_address,
|
||||||
|
|||||||
@@ -45,8 +45,8 @@ def register():
|
|||||||
# How do we report to the user there is a problem with
|
# How do we report to the user there is a problem with
|
||||||
# sending codes apart from service unavailable?
|
# sending codes apart from service unavailable?
|
||||||
# at the moment i believe http 500 is fine.
|
# at the moment i believe http 500 is fine.
|
||||||
users_dao.send_verify_code(user.id, 'sms')
|
users_dao.send_verify_code(user.id, 'sms', user.mobile_number)
|
||||||
users_dao.send_verify_code(user.id, 'email')
|
users_dao.send_verify_code(user.id, 'email', user.email_address)
|
||||||
session['expiry_date'] = str(datetime.now() + timedelta(hours=1))
|
session['expiry_date'] = str(datetime.now() + timedelta(hours=1))
|
||||||
session['user_details'] = {"email": user.email_address, "id": user.id}
|
session['user_details'] = {"email": user.email_address, "id": user.id}
|
||||||
return redirect(url_for('main.verify'))
|
return redirect(url_for('main.verify'))
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ def sign_in():
|
|||||||
if user.state == 'pending':
|
if user.state == 'pending':
|
||||||
return redirect(url_for('.verify'))
|
return redirect(url_for('.verify'))
|
||||||
elif user.is_active():
|
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'))
|
return redirect(url_for('.two_factor'))
|
||||||
# Vague error message for login in case of user not known, locked, inactive or password not verified
|
# Vague error message for login in case of user not known, locked, inactive or password not verified
|
||||||
flash('Username or password is incorrect')
|
flash('Username or password is incorrect')
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ def user_profile_email_authenticate():
|
|||||||
|
|
||||||
if form.validate_on_submit():
|
if form.validate_on_submit():
|
||||||
session[NEW_EMAIL_PASSWORD_CONFIRMED] = True
|
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 redirect(url_for('.user_profile_email_confirm'))
|
||||||
|
|
||||||
return render_template(
|
return render_template(
|
||||||
@@ -142,7 +142,7 @@ def user_profile_mobile_number_authenticate():
|
|||||||
|
|
||||||
if form.validate_on_submit():
|
if form.validate_on_submit():
|
||||||
session[NEW_MOBILE_PASSWORD_CONFIRMED] = True
|
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 redirect(url_for('.user_profile_mobile_number_confirm'))
|
||||||
|
|
||||||
return render_template(
|
return render_template(
|
||||||
|
|||||||
@@ -64,8 +64,8 @@ class UserApiClient(BaseAPIClient):
|
|||||||
return user[0]
|
return user[0]
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def send_verify_code(self, user_id, code_type, to=None):
|
def send_verify_code(self, user_id, code_type, to):
|
||||||
data = {'to': to} if to else {}
|
data = {'to': to}
|
||||||
endpoint = '/user/{0}/{1}-code'.format(user_id, code_type)
|
endpoint = '/user/{0}/{1}-code'.format(user_id, code_type)
|
||||||
resp = self.post(endpoint, data=data)
|
resp = self.post(endpoint, data=data)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user