aboutsummaryrefslogtreecommitdiff
path: root/api/user/modify.py
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2021-04-26 11:28:57 +0200
committerlonkaars <loek@pipeframe.xyz>2021-04-26 11:28:57 +0200
commit6f0d4d8afe376b7e109d5c531c21b5626fe76b03 (patch)
tree345c3ecdba8d4bb1def6a038016b09a2fbda8d87 /api/user/modify.py
parent62651f981fa6ac6c87ab95b8e52eeca60e80ed6a (diff)
dprint fmt
Diffstat (limited to 'api/user/modify.py')
-rw-r--r--api/user/modify.py18
1 files changed, 11 insertions, 7 deletions
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]]