aboutsummaryrefslogtreecommitdiff
path: root/api/auth
diff options
context:
space:
mode:
authorlonkaars <l.leblansch@gmail.com>2021-01-13 19:01:04 +0100
committerlonkaars <l.leblansch@gmail.com>2021-01-13 19:01:04 +0100
commit26631dadc7cf1406060f2574ce3dda484066ac6a (patch)
treea95cd6d94e1c0ee823cc777a1ba6b34681852af3 /api/auth
parent20ffb510f63d9d9cdabf0aca7343de1cb3b0bf22 (diff)
semi- user registration
Diffstat (limited to 'api/auth')
-rw-r--r--api/auth/signup.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/api/auth/signup.py b/api/auth/signup.py
new file mode 100644
index 0000000..df6a271
--- /dev/null
+++ b/api/auth/signup.py
@@ -0,0 +1,32 @@
+from flask import Blueprint, request
+from main import cursor, connection
+from randid import new_uuid
+import time
+import json
+
+signup = Blueprint('signup', __name__)
+
+@signup.route('/signup', methods = ['POST'])
+def index():
+ data = request.get_json()
+
+ username = data.get("username") or ""
+ email = data.get("email") or ""
+ password = data.get("password") or ""
+
+ if not username or \
+ not email or \
+ not password:
+ return "", 400
+
+ user_id = new_uuid()
+ password_salt = "salt"
+ password_hash = "hash"
+ registered = int( time.time() * 1000 )
+
+ cursor.execute("insert into users values (?, ?, ?, NULL, ?, ?, ?, NULL, FALSE, \"user\", \"{}\", NULL, \"online\") ",
+ (user_id, username, email, password_salt, password_hash, registered))
+
+ connection.commit()
+
+ return "", 200