diff options
author | lonkaars <loek@pipeframe.xyz> | 2021-04-26 11:28:22 +0200 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2021-04-26 11:28:22 +0200 |
commit | 62651f981fa6ac6c87ab95b8e52eeca60e80ed6a (patch) | |
tree | 9f3a5bf77967e9e29af4c0fdf37b553c8bd5f8b8 /api/auth | |
parent | cd89523e5d5411d82031949da040abcac6e88177 (diff) |
update username/email endpoints
Diffstat (limited to 'api/auth')
-rw-r--r-- | api/auth/login.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/api/auth/login.py b/api/auth/login.py index e3d5fde..e0cb406 100644 --- a/api/auth/login.py +++ b/api/auth/login.py @@ -3,6 +3,14 @@ from db import cursor import auth.token as token import passwords +def login_password(user_id, password): + passwd_hash = cursor.execute( + "select password_hash from users where user_id = ?", [user_id] + ).fetchone() + if not passwd_hash: return False + check = passwords.check_password(password, passwd_hash[0]) + return bool(check) + login = Blueprint('login', __name__) @@ -29,11 +37,8 @@ def index(): if user_id == None: return "", 401 # check the password - passwd = cursor.execute( - "select password_hash from users where user_id = ?", [user_id[0]] - ).fetchone() - check = passwords.check_password(password, passwd[0]) - if not check: return "", 401 + valid_password = login_password(user_id[0], password) + if not valid_password: return "", 401 # generate a new authentication token and add it to the users valid token list new_token = token.generate_token() |