mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-17 03:39:25 +00:00
Fixes login API errors
This commit is contained in:
@@ -59,6 +59,7 @@ class LoginHandler(BaseHandler):
|
|||||||
allowed_methods = ('GET')
|
allowed_methods = ('GET')
|
||||||
|
|
||||||
def read(self, request, id=None):
|
def read(self, request, id=None):
|
||||||
|
|
||||||
if id:
|
if id:
|
||||||
try:
|
try:
|
||||||
u = User.objects.get(id=id)
|
u = User.objects.get(id=id)
|
||||||
@@ -71,15 +72,16 @@ class LoginHandler(BaseHandler):
|
|||||||
except User.DoesNotExist:
|
except User.DoesNotExist:
|
||||||
return { 'auth': 'missing', 'missing': 'Username' }
|
return { 'auth': 'missing', 'missing': 'Username' }
|
||||||
|
|
||||||
d = { 'auth': 'ok', 'id': u.id, 'username': u.username,
|
if u:
|
||||||
|
if request.GET.get('pass', None) and request.GET['pass'] == u.get_profile().api_service_password:
|
||||||
|
return { 'auth': 'ok', 'id': u.id, 'username': u.username,
|
||||||
'email': u.email, 'groups': u.groups.all(),
|
'email': u.email, 'groups': u.groups.all(),
|
||||||
'staff': u.is_staff, 'superuser': u.is_superuser }
|
'staff': u.is_staff, 'superuser': u.is_superuser }
|
||||||
|
else:
|
||||||
if request.GET.get('pass', None) and request.GET['pass'] == u.get_profile().api_service_password:
|
|
||||||
return d
|
|
||||||
|
|
||||||
return { 'auth': 'failed' }
|
return { 'auth': 'failed' }
|
||||||
|
|
||||||
|
return { 'auth': 'missing', 'missing': 'all' }
|
||||||
|
|
||||||
|
|
||||||
class EveAPIHandler(BaseHandler):
|
class EveAPIHandler(BaseHandler):
|
||||||
allowed_methods = ('GET')
|
allowed_methods = ('GET')
|
||||||
|
|||||||
Reference in New Issue
Block a user