mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-14 14:52:15 +00:00
Fixes login API errors
This commit is contained in:
@@ -59,26 +59,28 @@ 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)
|
||||||
except (User.DoesNotExist, ValueError):
|
except (User.DoesNotExist, ValueError):
|
||||||
return { 'auth': 'missing', 'missing': 'UserID'}
|
return { 'auth': 'missing', 'missing': 'UserID' }
|
||||||
|
|
||||||
if request.GET.get('user', None):
|
if request.GET.get('user', None):
|
||||||
try:
|
try:
|
||||||
u = User.objects.get(username=request.GET['user'])
|
u = User.objects.get(username=request.GET['user'])
|
||||||
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:
|
||||||
'email': u.email, 'groups': u.groups.all(),
|
if request.GET.get('pass', None) and request.GET['pass'] == u.get_profile().api_service_password:
|
||||||
'staff': u.is_staff, 'superuser': u.is_superuser }
|
return { 'auth': 'ok', 'id': u.id, 'username': u.username,
|
||||||
|
'email': u.email, 'groups': u.groups.all(),
|
||||||
|
'staff': u.is_staff, 'superuser': u.is_superuser }
|
||||||
|
else:
|
||||||
|
return { 'auth': 'failed' }
|
||||||
|
|
||||||
if request.GET.get('pass', None) and request.GET['pass'] == u.get_profile().api_service_password:
|
return { 'auth': 'missing', 'missing': 'all' }
|
||||||
return d
|
|
||||||
|
|
||||||
return { 'auth': 'failed' }
|
|
||||||
|
|
||||||
|
|
||||||
class EveAPIHandler(BaseHandler):
|
class EveAPIHandler(BaseHandler):
|
||||||
|
|||||||
Reference in New Issue
Block a user