Adding login view and integrating oauth middleware and authentication backend. Wow that was easy.

This commit is contained in:
Samuel Clay 2014-01-15 15:41:18 -08:00
parent 61d6240694
commit c7d158a654
3 changed files with 10 additions and 2 deletions

View file

@ -744,6 +744,7 @@ def load_feed_page(request, feed_id):
logging.user(request, "~FYLoading original page, from the db")
return HttpResponse(data, mimetype="text/html; charset=utf-8")
@login_required()
@json.json_view
def load_starred_stories(request):
user = get_user(request)

View file

@ -101,6 +101,7 @@ MIDDLEWARE_CLASSES = (
'django.middleware.gzip.GZipMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'apps.profile.middleware.TimingMiddleware',
'apps.profile.middleware.LastSeenMiddleware',
@ -110,10 +111,14 @@ MIDDLEWARE_CLASSES = (
'apps.profile.middleware.SimpsonsMiddleware',
'apps.profile.middleware.ServerHostnameMiddleware',
'corsheaders.middleware.CorsMiddleware',
'oauth2_provider.middleware.OAuth2TokenMiddleware',
# 'debug_toolbar.middleware.DebugToolbarMiddleware',
)
AUTHENTICATION_BACKENDS = ('django.contrib.auth.backends.ModelBackend',)
AUTHENTICATION_BACKENDS = (
'oauth2_provider.backends.OAuth2Backend',
'django.contrib.auth.backends.ModelBackend',
)
CORS_ORIGIN_ALLOW_ALL = True

View file

@ -50,7 +50,9 @@ urlpatterns = patterns('',
url(r'^android/?', static_views.android, name='android-static'),
url(r'^firefox/?', static_views.firefox, name='firefox'),
url(r'zebra/', include('zebra.urls', namespace="zebra", app_name='zebra')),
(r'^account/login/?$', 'django.contrib.auth.views.login', {'template_name': 'accounts/login.html'}),
url(r'^account/login/?$',
'django.contrib.auth.views.login',
{'template_name': 'accounts/login.html'}, name='login'),
url(r'^account/', include('oauth2_provider.urls', namespace='oauth2_provider')),
)