mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-01 04:09:46 -04:00
109526520: Add custom validators for the VerifyForm
If the email_code or sms_code entered does not pass check password, then add errors to the form.
This commit is contained in:
@@ -3,7 +3,6 @@ from flask_login import login_user
|
||||
|
||||
from app.main import main
|
||||
from app.main.dao import users_dao
|
||||
from app.main.encryption import checkpw
|
||||
from app.main.forms import VerifyForm
|
||||
|
||||
|
||||
@@ -16,17 +15,10 @@ def render_verify():
|
||||
def process_verify():
|
||||
form = VerifyForm()
|
||||
if form.validate_on_submit():
|
||||
valid_sms = checkpw(form.sms_code.data, session['sms_code'])
|
||||
valid_email = checkpw(form.email_code.data, session['email_code'])
|
||||
if valid_sms is False:
|
||||
return jsonify(sms_code='does not match'), 400
|
||||
if valid_email is False:
|
||||
return jsonify(email_code='does not match'), 400
|
||||
user = users_dao.get_user_by_id(session['user_id'])
|
||||
users_dao.activate_user(user.id)
|
||||
login_user(user)
|
||||
return redirect('/add-service')
|
||||
else:
|
||||
print(form.errors)
|
||||
return jsonify(form.errors), 400
|
||||
|
||||
user = users_dao.get_user_by_id(session['user_id'])
|
||||
users_dao.activate_user(user.id)
|
||||
login_user(user)
|
||||
|
||||
return redirect('/add-service')
|
||||
|
||||
Reference in New Issue
Block a user