mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-14 14:52:15 +00:00
Small works on the API v2
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
from django.http import HttpResponse
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
|
|
||||||
from piston.handler import BaseHandler
|
from piston.handler import BaseHandler
|
||||||
@@ -28,11 +29,9 @@ class V2AuthenticationHandler(BaseHandler):
|
|||||||
return rc.BAD_REQUEST
|
return rc.BAD_REQUEST
|
||||||
|
|
||||||
try:
|
try:
|
||||||
user = User.object.get(username=username)
|
user = User.objects.get(username=username)
|
||||||
except User.DoesNotExist:
|
except User.DoesNotExist:
|
||||||
resp = rc.NOT_FOUND
|
return {'auth': 'notfound'}
|
||||||
resp.write({'auth': 'notfound'})
|
|
||||||
return resp
|
|
||||||
|
|
||||||
if password and password == user.get_profile().api_service_password:
|
if password and password == user.get_profile().api_service_password:
|
||||||
return {'userid': user.id,
|
return {'userid': user.id,
|
||||||
@@ -42,9 +41,7 @@ class V2AuthenticationHandler(BaseHandler):
|
|||||||
'staff': user.is_staff,
|
'staff': user.is_staff,
|
||||||
'superuser': user.is_superuser}
|
'superuser': user.is_superuser}
|
||||||
|
|
||||||
resp = rc.FORBIDDEN
|
return {'auth': 'failed'}
|
||||||
resp.write({'auth': 'failed'})
|
|
||||||
return resp
|
|
||||||
|
|
||||||
|
|
||||||
class V2EveAPIProxyHandler(BaseHandler):
|
class V2EveAPIProxyHandler(BaseHandler):
|
||||||
|
|||||||
Reference in New Issue
Block a user