mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-02 17:48:50 -04:00
109898688: All codes are valid until one code is used, then they are all marked used.
Fixed the is_active() method on the Users model, if the user was pending they would come back as active, allowing a user to sign in before being active. There is still a problem with the validate_sms_code and validate_email_code method.
This commit is contained in:
@@ -13,11 +13,11 @@ def add_code(user_id, code, code_type):
|
||||
|
||||
db.session.add(code)
|
||||
db.session.commit()
|
||||
return code.id
|
||||
|
||||
|
||||
def get_code(user_id, code_type):
|
||||
verify_code = VerifyCodes.query.filter_by(user_id=user_id, code_type=code_type, code_used=False).first()
|
||||
return verify_code
|
||||
def get_codes(user_id, code_type):
|
||||
return VerifyCodes.query.filter_by(user_id=user_id, code_type=code_type, code_used=False).all()
|
||||
|
||||
|
||||
def get_code_by_code(user_id, code, code_type):
|
||||
@@ -32,9 +32,10 @@ def use_code(id):
|
||||
|
||||
|
||||
def use_code_for_user_and_type(user_id, code_type):
|
||||
verify_code = VerifyCodes.query.filter_by(user_id=user_id, code_type=code_type).first()
|
||||
verify_code.code_used = True
|
||||
db.session.add(verify_code)
|
||||
codes = VerifyCodes.query.filter_by(user_id=user_id, code_type=code_type, code_used=False).all()
|
||||
for verify_code in codes:
|
||||
verify_code.code_used = True
|
||||
db.session.add(verify_code)
|
||||
db.session.commit()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user