Skip to content
Snippets Groups Projects
Verified Commit a6789846 authored by nd's avatar nd
Browse files

closes !2: only allow one valid token per kind at any given time

parent 6c07c5ea
No related branches found
No related tags found
No related merge requests found
...@@ -110,7 +110,8 @@ def token_mail(token): ...@@ -110,7 +110,8 @@ def token_mail(token):
def send_mail_verification(loginname, newmail): def send_mail_verification(loginname, newmail):
session = db.session session = db.session
expired_tokens = MailToken.query.filter(MailToken.created < (datetime.datetime.now() - datetime.timedelta(days=2))).all() expired_tokens = MailToken.query.filter(MailToken.created < (datetime.datetime.now() - datetime.timedelta(days=2))).all()
for i in expired_tokens: duplicate_tokens = MailToken.query.filter(MailToken.loginname == loginname).all()
for i in expired_tokens + duplicate_tokens:
session.delete(i) session.delete(i)
token = MailToken() token = MailToken()
token.loginname = loginname token.loginname = loginname
...@@ -128,7 +129,8 @@ def send_mail_verification(loginname, newmail): ...@@ -128,7 +129,8 @@ def send_mail_verification(loginname, newmail):
def send_passwordreset(loginname): def send_passwordreset(loginname):
session = db.session session = db.session
expired_tokens = PasswordToken.query.filter(PasswordToken.created < (datetime.datetime.now() - datetime.timedelta(days=2))).all() expired_tokens = PasswordToken.query.filter(PasswordToken.created < (datetime.datetime.now() - datetime.timedelta(days=2))).all()
for i in expired_tokens: duplicate_tokens = PasswordToken.query.filter(PasswordToken.loginname == loginname).all()
for i in expired_tokens + duplicate_tokens:
session.delete(i) session.delete(i)
token = PasswordToken() token = PasswordToken()
token.loginname = loginname token.loginname = loginname
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment