Permalink
Browse files

Started implementation of user auth.

  • Loading branch information...
1 parent c2fed86 commit 0bbcba4a6fadda14f2314bb7dde13eb4d26a852d @overshard committed Jul 6, 2012
Showing with 20 additions and 0 deletions.
  1. +14 −0 pinry/api/api.py
  2. +6 −0 pinry/api/urls.py
View
@@ -1,5 +1,9 @@
from tastypie.resources import ModelResource
from tastypie import fields
+from tastypie.authentication import BasicAuthentication
+from tastypie.authorization import DjangoAuthorization
+
+from django.contrib.auth.models import User
from pinry.pins.models import Pin
@@ -15,3 +19,13 @@ class Meta:
def dehydrate_thumbnail(self, bundle):
pin = Pin.objects.only('image').get(pk=bundle.data['id'])
return pin.image.url_200x1000
+
+
+class UserResource(ModelResource):
+ class Meta:
+ queryset = User.objects.all()
+ resource_name = 'auth/user'
+ excludes = ['email', 'password', 'is_superuser']
+ # Add it here.
+ authentication = BasicAuthentication()
+ authorization = DjangoAuthorization()
View
@@ -1,8 +1,14 @@
from django.conf.urls import patterns, include, url
+
from .api import PinResource
+from .api import UserResource
+
pin_resource = PinResource()
+user_resource = UserResource()
+
urlpatterns = patterns('',
url(r'', include(pin_resource.urls)),
+ url(r'', include(user_resource.urls)),
)

0 comments on commit 0bbcba4

Please sign in to comment.