Set the expiry time on a verify code (2fa) to 10 minutes.

When the verify code is wrong or expired increment the failed to login count for the user.
When the verify code is successfully used reset the failed login count to 0.
This commit is contained in:
Rebecca Law
2017-02-14 14:04:11 +00:00
parent b2267ae5fc
commit 5f48367ee5
3 changed files with 148 additions and 182 deletions

View File

@@ -123,10 +123,13 @@ def verify_user_code(user_id):
code = get_user_code(user_to_verify, txt_code, txt_type)
if not code:
increment_failed_login_count(user_to_verify)
raise InvalidRequest("Code not found", status_code=404)
if datetime.utcnow() > code.expiry_datetime or code.code_used:
increment_failed_login_count(user_to_verify)
raise InvalidRequest("Code has expired", status_code=400)
use_user_code(code.id)
reset_failed_login_count(user_to_verify)
return jsonify({}), 204