summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--server/handlers.py5
-rw-r--r--server/user_session.py9
2 files changed, 7 insertions, 7 deletions
diff --git a/server/handlers.py b/server/handlers.py
index 902cdbb..0b3dd46 100644
--- a/server/handlers.py
+++ b/server/handlers.py
@@ -41,13 +41,12 @@ class Login(CodeqService):
else:
session = request.session
try:
- session.login(username, password)
+ name, email, date_joined, last_login = session.login(username, password)
except AuthenticationFailed:
request.reply({'code': 3, 'message': 'Username or password do not match'})
else:
settings = session.get_settings()
- request.reply({'code': 0, 'message': 'OK', 'settings': settings})
-
+ request.reply({'code': 0, 'message': 'OK', 'name': name, 'email' : email, 'joined' : date_joined.isoformat(), 'last-login' : last_login.isoformat(), 'settings': settings})
class Logout(CodeqService):
def process(self, request):
diff --git a/server/user_session.py b/server/user_session.py
index cd82580..6a994f3 100644
--- a/server/user_session.py
+++ b/server/user_session.py
@@ -61,12 +61,12 @@ class UserSession(object):
def login(self, username, password):
with self._access_lock:
- now = datetime.datetime.now()
+ now = datetime.datetime.utcnow()
conn = db.get_connection()
try:
cur = conn.cursor()
try:
- cur.execute('select id, password, gui_lang from codeq_user where username = %s', (username,))
+ cur.execute('select id, password, name, email, date_joined, gui_lang from codeq_user where username = %s', (username,))
row = cur.fetchone()
if row is None:
raise AuthenticationFailed('No such user: {}'.format(username))
@@ -74,7 +74,8 @@ class UserSession(object):
cur.execute('update codeq_user set last_login = %s where id = %s', (str(now), row[0],))
self.uid = row[0]
self.username = username
- self.settings = {'lang': row[2]}
+ self.settings = {'lang': row[5]}
+ return row[2], row[3], row[4], now
else:
raise AuthenticationFailed('Password mismatch')
finally:
@@ -85,7 +86,7 @@ class UserSession(object):
def signup(self, username, name, email, password, lang):
with self._access_lock:
- now = datetime.datetime.now()
+ now = datetime.datetime.utcnow()
conn = db.get_connection()
try:
cur = conn.cursor()