Switched basic out to "Login" and switched User to oauth, in prep for dreddit_oauth.

This commit is contained in:
2010-06-10 10:13:59 +01:00
parent c73ba0c148
commit 635e81499f
2 changed files with 31 additions and 3 deletions

View File

@@ -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

View File

@@ -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',