Only actually call api to verify code if both are present in form.

This commit is contained in:
Adam Shimali
2016-03-10 14:48:33 +00:00
parent 8c250a7853
commit 54f871dfba
3 changed files with 30 additions and 8 deletions

View File

@@ -168,10 +168,12 @@ class VerifyForm(Form):
raise ValidationError(reason)
def validate_email_code(self, field):
self._validate_code(field.data, 'email')
if self.sms_code.data:
self._validate_code(field.data, 'email')
def validate_sms_code(self, field):
self._validate_code(field.data, 'sms')
if self.email_code.data:
self._validate_code(field.data, 'sms')
class EmailNotReceivedForm(Form):

View File

@@ -24,6 +24,7 @@ def verify():
def _check_code(code, code_type):
return users_dao.check_verify_code(user_id, code, code_type)
form = VerifyForm(_check_code)
if form.validate_on_submit():
try:
@@ -37,6 +38,6 @@ def verify():
else:
raise e
finally:
del session['user_details']
session.pop('user_details', None)
return render_template('views/verify.html', form=form)