Turn on redirects two_factor

This is part of the work to make sure user is redirected
to the page they initially were meant to visit after
they sign in.
This commit is contained in:
Pea Tyczynska
2020-10-09 11:42:21 +01:00
parent a531c888ba
commit 44ddee23ac
3 changed files with 22 additions and 8 deletions

View File

@@ -70,15 +70,16 @@ def two_factor():
return user_api_client.check_verify_code(user_id, code, "sms")
form = TwoFactorForm(_check_code)
redirect_url = request.args.get('next')
if form.validate_on_submit():
if is_less_than_90_days_ago(user.email_access_validated_at):
return log_in_user(user_id)
else:
user_api_client.send_verify_code(user.id, 'email', None, request.args.get('next'))
return redirect(url_for('.revalidate_email_sent'))
user_api_client.send_verify_code(user.id, 'email', None, redirect_url)
return redirect(url_for('.revalidate_email_sent', next=redirect_url))
return render_template('views/two-factor.html', form=form)
return render_template('views/two-factor.html', form=form, redirect_url=redirect_url)
@main.route('/re-validate-email', methods=['GET'])

View File

@@ -22,7 +22,7 @@
}) }}
{{ page_footer(
"Continue",
secondary_link=url_for('main.check_and_resend_text_code'),
secondary_link=url_for('main.check_and_resend_text_code', next=redirect_url),
secondary_link_text='Not received a text message?'
) }}
{% endcall %}