mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-14 14:52:15 +00:00
added the "admin" field to the login endpoint, showing what groups the user is admin of
This commit is contained in:
@@ -98,8 +98,17 @@ class LoginHandler(BaseHandler):
|
||||
pchardict['alliance'] = None
|
||||
else:
|
||||
pchardict = None
|
||||
|
||||
glist = []
|
||||
for g in u.groups.all():
|
||||
if u in g.groupinformation.admins.all():
|
||||
admin = True
|
||||
else:
|
||||
admin = False
|
||||
glist.append({'id': g.id, 'name': g.name, 'admin': admin})
|
||||
|
||||
return {'auth': 'ok', 'id': u.id, 'username': u.username,
|
||||
'email': u.email, 'groups': u.groups.all().values('id', 'name'),
|
||||
'email': u.email, 'groups': glist,
|
||||
'staff': u.is_staff, 'superuser': u.is_superuser, 'primarycharacter': pchardict}
|
||||
else:
|
||||
return {'auth': 'failed', 'error': 'password'}
|
||||
|
||||
Reference in New Issue
Block a user