summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/handlers.py14
-rw-r--r--server/user_session.py6
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: