aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--api/auth/signup.py9
-rw-r--r--api/user/info.py4
-rw-r--r--database/init_db.sql1
3 files changed, 8 insertions, 6 deletions
diff --git a/api/auth/signup.py b/api/auth/signup.py
index 210ba94..d5d178a 100644
--- a/api/auth/signup.py
+++ b/api/auth/signup.py
@@ -6,14 +6,17 @@ import passwords
import time
import re
+# Checks wheter the usename (at signup) exist of at least 3 and at most 35 charachters
def validate_username(username):
- return len(username) in range(3, 35 + 1)
+ return len(username) in range(3, 35 + 1)
+# Checks if there's an '@' in the email (at signup) and if there's any input at all
def validate_email(email):
#TODO: use node_modules/email-validator/index.js
return len(email) > 1 and \
"@" in email
+# Checks wheter the signed up password consist of an uppercase, lowercase and a digit & the minimal length is 8 charachters
def validate_password(password):
passwordRegex = r"^(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9]).{8,}$" # r"" = raw string
return re.match(passwordRegex, password)
@@ -22,6 +25,7 @@ signup = Blueprint('signup', __name__)
@signup.route('/signup', methods = ['POST'])
def index():
+ # Requests information from endpoint 'signup', recieves username, email and password. It can also recieve an empty string, in that case the program will stop and return error code/http code '400'
data = request.get_json()
username = data.get("username") or ""
@@ -33,6 +37,7 @@ def index():
not password:
return "", 400
+ #
if not validate_username(username) or \
not validate_email(email) or \
not validate_password(password):
@@ -48,7 +53,7 @@ def index():
password_hash = passwords.password_hash(password)
registered = int( time.time() * 1000 )
- cursor.execute("insert into users values (?, ?, ?, NULL, NULL, ?, ?, \"[]\", FALSE, \"user\", \"{}\", NULL, \"online\") ",
+ cursor.execute("insert into users values (?, ?, ?, NULL, NULL, ?, ?, \"[]\", FALSE, \"user\", \"{}\", \"online\") ",
(user_id, username, email, password_hash, registered))
connection.commit()
diff --git a/api/user/info.py b/api/user/info.py
index a9594aa..9a48f4d 100644
--- a/api/user/info.py
+++ b/api/user/info.py
@@ -29,7 +29,6 @@ def format_user(user_id, viewer = ''):
"user_id",
"country",
"registered",
- "avatar",
"status",
]) + " from users where user_id = ?", [user_id]).fetchone()
formatted_user = {
@@ -37,8 +36,7 @@ def format_user(user_id, viewer = ''):
"id": user[1],
"country": user[2],
"registered": user[3],
- "avatar": user[4],
- "status": user[5],
+ "status": user[4],
"friends": count_friends(user_id),
"rating": get_rating(user_id),
}
diff --git a/database/init_db.sql b/database/init_db.sql
index d05af6e..cd52e2e 100644
--- a/database/init_db.sql
+++ b/database/init_db.sql
@@ -12,7 +12,6 @@ create table if not exists users (
verified_email boolean not null,
type text not null,
preferences text not null,
- avatar text,
presence text
);