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 return True
def check_user(self, profileId, token, user): def check_user(self, profileId, token, user):
with self.connect() as c: with self.connect() as con:
res = c.execute("SELECT user FROM users WHERE profileId=?", with con.cursor() as c:
(profileId,)).fetchone() res = c.execute("SELECT user FROM users WHERE profileId=?",
if res is not None: (profileId,)).fetchone()
return res[0] == user 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=?", # Check if new user can be created
(user,)).fetchone() res = c.execute("SELECT 1 FROM new WHERE user=?",
if res is None or res[0] != 1: (user,)).fetchone()
return False if res is None or res[0] != 1:
c.execute("DELETE FROM new WHERE user=?", (user,)) return False
# Create new user # Create new user
c.execute("INSERT INTO users VALUES (?, ?, ?)", c.execute("DELETE FROM new WHERE user=?", (user,))
(profileId, token, user)) c.execute("INSERT INTO users VALUES (?, ?, ?)",
(profileId, token, user))
return True return True
def get_user(self, profileId): def get_user(self, profileId):

Loading…
Cancel
Save