This commit is contained in:
Kenneth Kehl
2024-08-19 10:57:08 -07:00
parent 5a3f3e5ca0
commit 672fed7e4b
3 changed files with 25 additions and 26 deletions

View File

@@ -189,32 +189,30 @@ def user_profile_mobile_number_delete():
@main.route("/user-profile/mobile-number/authenticate", methods=["GET", "POST"])
@user_is_logged_in
def user_profile_mobile_number_authenticate():
# Validate password for form
def _check_password(pwd):
return user_api_client.verify_password(current_user.id, pwd)
form = ConfirmPasswordForm(_check_password)
if NEW_MOBILE not in session:
return redirect(url_for(".user_profile_mobile_number"))
if form.validate_on_submit():
session[NEW_MOBILE_PASSWORD_CONFIRMED] = True
current_user.send_verify_code(to=session[NEW_MOBILE])
create_mobile_number_change_event(
user_id=current_user.id,
updated_by_id=current_user.id,
original_mobile_number=current_user.mobile_number,
new_mobile_number=session[NEW_MOBILE],
)
return redirect(url_for(".user_profile_mobile_number_confirm"))
return render_template(
"views/user-profile/authenticate.html",
thing="mobile number",
form=form,
back_link=url_for(".user_profile_mobile_number_confirm"),
session[NEW_MOBILE_PASSWORD_CONFIRMED] = True
print(f"GOING TO SEND VERIFY CODE TO {session[NEW_MOBILE]}")
current_user.send_verify_code(to=session[NEW_MOBILE])
create_mobile_number_change_event(
user_id=current_user.id,
updated_by_id=current_user.id,
original_mobile_number=current_user.mobile_number,
new_mobile_number=session[NEW_MOBILE],
)
print(
f"sent create_mobile_number_change_event original {current_user.mobile_number} new {session[NEW_MOBILE]}"
)
return redirect(url_for(".user_profile_mobile_number_confirm"))
# return render_template(
# "views/user-profile/authenticate.html",
# thing="mobile number",
# form=form,
# back_link=url_for(".user_profile_mobile_number_confirm"),
# )
@main.route("/user-profile/mobile-number/confirm", methods=["GET", "POST"])