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:
Rebecca Law
2015-12-16 12:20:25 +00:00
parent bd8bb3c926
commit 64812c1614
18 changed files with 259 additions and 203 deletions

View File

@@ -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()