mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-14 06:42:16 +00:00
Switched basic out to "Login" and switched User to oauth, in prep for dreddit_oauth.
This commit is contained in:
@@ -30,6 +30,32 @@ class UserHandler(BaseHandler):
|
||||
except ServiceAccount.DoesNotExist:
|
||||
return rc.NOT_HERE
|
||||
|
||||
d = { 'id': u.id, 'username': u.username, 'password': u.password, 'serviceaccounts': u.serviceaccount_set.all(),
|
||||
'eveapi': u.eveaccount_set.all(), 'email': u.email }
|
||||
chars = []
|
||||
for a in u.eveaccount_set.all():
|
||||
chars.append(a.characters.all())
|
||||
|
||||
d = { 'id': u.id, 'username': u.username, 'email': u.email,
|
||||
'serviceaccounts': u.serviceaccount_set.all(), 'characters': chars,
|
||||
'groups': u.groups.all() }
|
||||
|
||||
return d
|
||||
|
||||
class LoginHandler(BaseHandler):
|
||||
allowed_methods = ('GET')
|
||||
|
||||
def read(self, request, id=None):
|
||||
if id:
|
||||
try:
|
||||
u = User.objects.get(id=id)
|
||||
except (User.DoesNotExist, ValueError):
|
||||
return rc.NOT_HERE
|
||||
|
||||
if 'user' in request.GET:
|
||||
try:
|
||||
u = User.objects.get(username=request.GET['user'])
|
||||
except User.DoesNotExist:
|
||||
return rc.NOT_HERE
|
||||
|
||||
d = { 'id': u.id, 'username': u.username, 'password': u.password, 'email': u.email, 'groups': u.groups.all() }
|
||||
return d
|
||||
|
||||
|
||||
@@ -7,10 +7,12 @@ from api.handlers import *
|
||||
oauth = { 'authentication': OAuthAuthentication() }
|
||||
noauth = { 'authentication': NoAuthentication() }
|
||||
|
||||
user_resource = Resource(handler=UserHandler, **noauth)
|
||||
user_resource = Resource(handler=UserHandler, **oauth)
|
||||
login_resource = Resource(handler=LoginHandler, **noauth)
|
||||
|
||||
urlpatterns = patterns('',
|
||||
url(r'^user/$', user_resource),
|
||||
url(r'^login/$, login_resource),
|
||||
)
|
||||
|
||||
urlpatterns += patterns('piston.authentication',
|
||||
|
||||
Reference in New Issue
Block a user