aboutsummaryrefslogtreecommitdiff
path: root/api/auth/signup.py
diff options
context:
space:
mode:
authorlonkaars <l.leblansch@gmail.com>2021-04-11 18:03:11 +0200
committerlonkaars <l.leblansch@gmail.com>2021-04-11 18:03:11 +0200
commitdeb09e5c749e3353c927d7fe94bbd35f25ff85ee (patch)
tree702ba982530aa98a96ddece365a32be842dae3c2 /api/auth/signup.py
parent28f104de9ae9abe4b42abafbf3865ede5687996c (diff)
dprint yapf continuation align style edit
Diffstat (limited to 'api/auth/signup.py')
-rw-r--r--api/auth/signup.py26
1 files changed, 13 insertions, 13 deletions
diff --git a/api/auth/signup.py b/api/auth/signup.py
index f9a1af5..5e74076 100644
--- a/api/auth/signup.py
+++ b/api/auth/signup.py
@@ -16,7 +16,7 @@ def validate_username(username):
def validate_email(email):
#TODO: use node_modules/email-validator/index.js
return len(email) > 1 and \
- "@" in email
+ "@" in email
# checks if the password is safe (regex explanation in pages/register.tsx)
@@ -40,26 +40,26 @@ def index():
# return 400 (malformed request) if any of the required data is missing
if not username or \
- not email or \
- not password:
+ not email or \
+ not password:
return "", 400
# return 403 (forbidden) if any of the required data is invalid
if not validate_username(username) or \
- not validate_email(email) or \
- not validate_password(password):
+ not validate_email(email) or \
+ not validate_password(password):
return {"error": "form_data_invalid"}, 403
# check if username is taken
if cursor.execute(
- "select username from users where lower(username) = lower(?)",
- [username]
+ "select username from users where lower(username) = lower(?)",
+ [username]
).fetchone():
return {"error": "username_taken"}, 403
# check if email is taken
if cursor.execute("select email from users where email = ?",
- [email]).fetchone():
+ [email]).fetchone():
return {"error": "email_taken"}, 403
# create new user_id, hash password and note timestamp
@@ -69,8 +69,8 @@ def index():
# write new user to database and commit
cursor.execute(
- "insert into users values (?, ?, ?, NULL, NULL, ?, ?, \"[]\", FALSE, \"user\", \"{}\", \"online\") ",
- (user_id, username, email, password_hash, registered)
+ "insert into users values (?, ?, ?, NULL, NULL, ?, ?, \"[]\", FALSE, \"user\", \"{}\", \"online\") ",
+ (user_id, username, email, password_hash, registered)
)
connection.commit()
@@ -81,9 +81,9 @@ def index():
# create a flask response object to add the set-cookie header to
res = make_response("", 200)
res.set_cookie(
- "token",
- new_token["token"],
- expires=int(new_token["expirationDate"] / 1000)
+ "token",
+ new_token["token"],
+ expires=int(new_token["expirationDate"] / 1000)
)
return res