diff options
author | lonkaars <loek@pipeframe.xyz> | 2021-04-26 11:28:57 +0200 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2021-04-26 11:28:57 +0200 |
commit | 6f0d4d8afe376b7e109d5c531c21b5626fe76b03 (patch) | |
tree | 345c3ecdba8d4bb1def6a038016b09a2fbda8d87 | |
parent | 62651f981fa6ac6c87ab95b8e52eeca60e80ed6a (diff) |
dprint fmt
-rw-r--r-- | api/auth/login.py | 2 | ||||
-rw-r--r-- | api/user/modify.py | 18 | ||||
-rw-r--r-- | dprint.json | 3 |
3 files changed, 15 insertions, 8 deletions
diff --git a/api/auth/login.py b/api/auth/login.py index e0cb406..b787a54 100644 --- a/api/auth/login.py +++ b/api/auth/login.py @@ -3,6 +3,7 @@ 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] @@ -11,6 +12,7 @@ def login_password(user_id, password): check = passwords.check_password(password, passwd_hash[0]) return bool(check) + login = Blueprint('login', __name__) diff --git a/api/user/modify.py b/api/user/modify.py index a8066a1..f67b2ab 100644 --- a/api/user/modify.py +++ b/api/user/modify.py @@ -16,6 +16,7 @@ def login_and_password(func): if not login_password(user_id, password): return "", 401 return func(user_id) + return wrapper @@ -29,13 +30,20 @@ def modify_user_info(type): if not new_value: return "", 401 # check if already taken - taken = cursor.execute(f"select count(user_id) from users where lower({type}) = lower(?)", [new_value]).fetchone() + taken = cursor.execute( + f"select count(user_id) from users where lower({type}) = lower(?)", + [new_value] + ).fetchone() if taken[0] > 0: return "", 403 # update - cursor.execute(f"update users set {type} = ? where user_id = ?", [new_value, user_id]) + cursor.execute( + f"update users set {type} = ? where user_id = ?", + [new_value, user_id] + ) connection.commit() return "", 200 + return index @@ -49,8 +57,4 @@ modify_email.add_url_rule( '/email', 'route', modify_user_info("email"), methods=["POST"] ) - -dynamic_routes = [ - ["/user", modify_username], - ["/user", modify_email] - ] +dynamic_routes = [["/user", modify_username], ["/user", modify_email]] diff --git a/dprint.json b/dprint.json index 28e296f..f370849 100644 --- a/dprint.json +++ b/dprint.json @@ -34,7 +34,8 @@ "database/SQLiteFuzzySearch/**", "venv/**", ".next/**", - "news/**" + "news/**", + "api/readme.md" ], "plugins": [ "https://plugins.dprint.dev/typescript-0.44.0.wasm", |