Browse Source

Fix 4

master
mid-kid 3 weeks ago
parent
commit
d816cd1912
  1. 33
      auth/auth.py

33
auth/auth.py

@ -29,22 +29,23 @@ class Authentication:
return True
def check_user(self, profileId, token, user):
with self.connect() as c:
res = c.execute("SELECT user FROM users WHERE profileId=?",
(profileId,)).fetchone()
if res is not None:
return res[0] == user
# Check if new user can be created
res = c.execute("SELECT 1 FROM new WHERE user=?",
(user,)).fetchone()
if res is None or res[0] != 1:
return False
c.execute("DELETE FROM new WHERE user=?", (user,))
# Create new user
c.execute("INSERT INTO users VALUES (?, ?, ?)",
(profileId, token, user))
with self.connect() as con:
with con.cursor() as c:
res = c.execute("SELECT user FROM users WHERE profileId=?",
(profileId,)).fetchone()
if res is not None:
return res[0] == user
# Check if new user can be created
res = c.execute("SELECT 1 FROM new WHERE user=?",
(user,)).fetchone()
if res is None or res[0] != 1:
return False
# Create new user
c.execute("DELETE FROM new WHERE user=?", (user,))
c.execute("INSERT INTO users VALUES (?, ?, ?)",
(profileId, token, user))
return True
def get_user(self, profileId):

Loading…
Cancel
Save