diff options
author | Timotej Lazar <timotej.lazar@fri.uni-lj.si> | 2015-12-10 17:42:03 +0100 |
---|---|---|
committer | Timotej Lazar <timotej.lazar@fri.uni-lj.si> | 2015-12-11 16:11:15 +0100 |
commit | 8139494300d3ddef1eb4ff60f6a10c5023d91bd0 (patch) | |
tree | e6bf3c10c72d1c939426cef898aee3d653e32755 /server | |
parent | b73cb3fa7117570843a15d8e86c491c5d9ad54fd (diff) |
Return is_admin field on login
Diffstat (limited to 'server')
-rw-r--r-- | server/handlers.py | 14 | ||||
-rw-r--r-- | server/user_session.py | 6 |
2 files changed, 15 insertions, 5 deletions
diff --git a/server/handlers.py b/server/handlers.py index 918067f..56d07cd 100644 --- a/server/handlers.py +++ b/server/handlers.py @@ -61,12 +61,22 @@ class Login(CodeqService): else: session = request.session try: - name, email, date_joined, last_login = session.login(username, password) + name, email, is_admin, 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', 'username': username, 'name': name, 'email' : email, 'joined' : date_joined.isoformat(), 'last-login' : last_login.isoformat(), 'settings': settings}) + request.reply({ + 'code': 0, + 'message': 'OK', + 'username': username, + 'name': name, + 'email': email, + 'admin': is_admin, + 'joined': date_joined.isoformat(), + 'last-login': last_login.isoformat(), + 'settings': settings + }) class Logout(CodeqService): diff --git a/server/user_session.py b/server/user_session.py index 906f610..900238c 100644 --- a/server/user_session.py +++ b/server/user_session.py @@ -85,7 +85,7 @@ class UserSession(object): try: cur = conn.cursor() try: - cur.execute('select id, password, name, email, date_joined, gui_lang, robot_address, gui_layout from codeq_user where username = %s', (username,)) + cur.execute('select id, password, name, email, is_admin, date_joined, gui_lang, robot_address, gui_layout from codeq_user where username = %s', (username,)) row = cur.fetchone() if row is None: raise AuthenticationFailed('No such user: {}'.format(username)) @@ -93,8 +93,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 = {'gui_lang': row[5], 'robot_address': row[6], 'gui_layout': row[7]} - return row[2], row[3], row[4], now + self.settings = {'gui_lang': row[6], 'robot_address': row[7], 'gui_layout': row[8]} + return row[2], row[3], row[4], row[5], now else: raise AuthenticationFailed('Password mismatch') finally: |