fine-tuning login
This commit is contained in:
@ -12,6 +12,10 @@ class Model:
|
||||
if len(self.cursor.fetchall()) == 0:
|
||||
self.cursor.execute("INSERT INTO accounts (email) VALUES (%s)", (email, ))
|
||||
|
||||
self.cursor.execute("SELECT token FROM logintokens WHERE email = %s", (email, ))
|
||||
if len(self.cursor.fetchall()) > 2:
|
||||
return None
|
||||
|
||||
token = generate()
|
||||
self.cursor.execute("INSERT INTO logintokens (email, token) VALUES (%s, %s)", (email, token))
|
||||
self.connection.commit()
|
||||
@ -22,7 +26,8 @@ class Model:
|
||||
self.cursor.execute("SELECT email FROM logintokens WHERE token = %s", (token, ))
|
||||
rows = self.cursor.fetchall()
|
||||
if len(rows) > 0:
|
||||
self.cursor.execute("DELETE FROM logintokens WHERE token = %s", (token, ))
|
||||
email = rows[0][0]
|
||||
self.cursor.execute("DELETE FROM logintokens WHERE email = %s", (email, ))
|
||||
self.connection.commit()
|
||||
return rows[0][0]
|
||||
return email
|
||||
return None
|
Reference in New Issue
Block a user