diff options
author | Marko Pušnik <marko.pusnik@guru.si> | 2015-10-12 14:27:36 +0200 |
---|---|---|
committer | Marko Pušnik <marko.pusnik@guru.si> | 2015-10-12 14:27:36 +0200 |
commit | 3b2eb75e35aea371e4930737a4ce3d884fd3a92d (patch) | |
tree | 4f5a0d10eaa8cae6799cd68c84af7c82a8d19261 | |
parent | 7ab74a08a68bcb3afce03b089e57df5aff66bdd9 (diff) |
attributes for profile page
-rw-r--r-- | server/handlers.py | 5 | ||||
-rw-r--r-- | server/user_session.py | 9 |
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() |