aboutsummaryrefslogtreecommitdiff
path: root/api/auth/login_token.py
diff options
context:
space:
mode:
authorlonkaars <l.leblansch@gmail.com>2021-04-16 16:57:26 +0200
committerlonkaars <l.leblansch@gmail.com>2021-04-16 16:57:26 +0200
commit07c2b124e4348b15f1e5ec18c6cdfd77248c6bc8 (patch)
treee4a29123d3ebedc1d25500390c904c66b3b02489 /api/auth/login_token.py
parentaa2c999702dadba2afbcf2be9f597f890aafcc87 (diff)
spaces > tabs in python :(
Diffstat (limited to 'api/auth/login_token.py')
-rw-r--r--api/auth/login_token.py20
1 files changed, 10 insertions, 10 deletions
diff --git a/api/auth/login_token.py b/api/auth/login_token.py
index b5b1579..de770b3 100644
--- a/api/auth/login_token.py
+++ b/api/auth/login_token.py
@@ -5,12 +5,12 @@ from auth.token import validate_token, hash_token
# get user_id from authentication token
def token_login(token):
- hashed = hash_token({"token": token, "expirationDate": 0})
- user_id = cursor.execute(
- "select user_id from users where valid_tokens like ?",
- [f"%{hashed['token']}%"]
- ).fetchone()
- return None if not user_id else user_id[0]
+ hashed = hash_token({"token": token, "expirationDate": 0})
+ user_id = cursor.execute(
+ "select user_id from users where valid_tokens like ?",
+ [f"%{hashed['token']}%"]
+ ).fetchone()
+ return None if not user_id else user_id[0]
token = Blueprint('token', __name__)
@@ -19,12 +19,12 @@ token = Blueprint('token', __name__)
# this endpoint is currently unused, but verifies that a token is valid
@token.route('/token', methods=['POST'])
def index():
- data = request.get_json()
+ data = request.get_json()
- auth_token = data.get("token") or ""
- if not auth_token: return "", 400
+ auth_token = data.get("token") or ""
+ if not auth_token: return "", 400
- return "", 200 if token_login(auth_token) else 401
+ return "", 200 if token_login(auth_token) else 401
dynamic_route = ["/auth", token]