summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--server/handlers.py12
-rw-r--r--server/user_session.py4
2 files changed, 10 insertions, 6 deletions
diff --git a/server/handlers.py b/server/handlers.py
index 1ab09f3..902cdbb 100644
--- a/server/handlers.py
+++ b/server/handlers.py
@@ -59,19 +59,23 @@ class Signup(CodeqService):
def process(self, request):
js = request.data
username = js.get('username')
+ name = js.get('name')
+ email = js.get('email')
password = js.get('password')
lang = js.get('lang') or 'en'
if username is None:
request.reply({'code': 1, 'message': 'Username was not provided'})
+ if email is None:
+ request.reply({'code': 2, 'message': 'Email was not provided'})
elif password is None:
- request.reply({'code': 2, 'message': 'Password was not provided'})
+ request.reply({'code': 3, 'message': 'Password was not provided'})
else:
try:
- request.session.signup(username, password, lang)
+ request.session.signup(username, name, email, password, lang)
except UserExists:
- request.reply({'code': 3, 'message': 'Username already exists'})
+ request.reply({'code': 10, 'message': 'Username already exists'})
except SignupFailed:
- request.reply({'code': 4, 'message': 'Sign-up failed'})
+ request.reply({'code': 11, 'message': 'Sign-up failed'})
else:
request.reply({'code': 0, 'message': 'OK'})
diff --git a/server/user_session.py b/server/user_session.py
index cf5e120..cd82580 100644
--- a/server/user_session.py
+++ b/server/user_session.py
@@ -83,7 +83,7 @@ class UserSession(object):
conn.commit()
db.return_connection(conn)
- def signup(self, username, password, lang):
+ def signup(self, username, name, email, password, lang):
with self._access_lock:
now = datetime.datetime.now()
conn = db.get_connection()
@@ -95,7 +95,7 @@ class UserSession(object):
if row:
raise UserExists('User exists')
else:
- cur.execute('insert into codeq_user (username, password, name, email, is_admin, is_active, date_joined, last_login, gui_lang) values (%s, %s, %s, %s, %s, %s, %s, %s, %s) returning id', (username, encrypt_password(password), None ,'', False, True, str(now), str(now), lang))
+ cur.execute('insert into codeq_user (username, password, name, email, is_admin, is_active, date_joined, last_login, gui_lang) values (%s, %s, %s, %s, %s, %s, %s, %s, %s) returning id', (username, encrypt_password(password), name, email, False, True, str(now), str(now), lang))
row = cur.fetchone()
if row is None:
raise SignupFailed('Sign-up failed')