Added basic auth endpoints
This commit is contained in:
parent
97133d068c
commit
65f05ea0ef
|
@ -25,3 +25,8 @@ django-filer==0.9.8
|
||||||
|
|
||||||
# Blog
|
# Blog
|
||||||
django-ckeditor-updated==4.4.4
|
django-ckeditor-updated==4.4.4
|
||||||
|
|
||||||
|
# API
|
||||||
|
djoser==0.2.1
|
||||||
|
djangorestframework==3.1.1
|
||||||
|
django-cors-headers==1.0.0
|
||||||
|
|
|
@ -70,6 +70,12 @@ INSTALLED_APPS = (
|
||||||
'shelfzilla.apps.manga',
|
'shelfzilla.apps.manga',
|
||||||
'shelfzilla.apps.blog',
|
'shelfzilla.apps.blog',
|
||||||
'shelfzilla.apps.pjax',
|
'shelfzilla.apps.pjax',
|
||||||
|
|
||||||
|
# API
|
||||||
|
'corsheaders',
|
||||||
|
'rest_framework',
|
||||||
|
'rest_framework.authtoken',
|
||||||
|
'djoser',
|
||||||
)
|
)
|
||||||
|
|
||||||
TEMPLATE_CONTEXT_PROCESSORS = (
|
TEMPLATE_CONTEXT_PROCESSORS = (
|
||||||
|
@ -94,6 +100,7 @@ TEMPLATE_CONTEXT_PROCESSORS = (
|
||||||
MIDDLEWARE_CLASSES = (
|
MIDDLEWARE_CLASSES = (
|
||||||
'reversion.middleware.RevisionMiddleware',
|
'reversion.middleware.RevisionMiddleware',
|
||||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||||
|
'corsheaders.middleware.CorsMiddleware',
|
||||||
'django.middleware.common.CommonMiddleware',
|
'django.middleware.common.CommonMiddleware',
|
||||||
'django.middleware.locale.LocaleMiddleware',
|
'django.middleware.locale.LocaleMiddleware',
|
||||||
'django.middleware.csrf.CsrfViewMiddleware',
|
'django.middleware.csrf.CsrfViewMiddleware',
|
||||||
|
@ -297,3 +304,24 @@ CKEDITOR_CONFIGS = {
|
||||||
# AUTH
|
# AUTH
|
||||||
#
|
#
|
||||||
AUTH_USER_MODEL = 'account.User'
|
AUTH_USER_MODEL = 'account.User'
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# API
|
||||||
|
#
|
||||||
|
CORS_ORIGIN_ALLOW_ALL = True
|
||||||
|
|
||||||
|
REST_FRAMEWORK = {
|
||||||
|
'DEFAULT_AUTHENTICATION_CLASSES': (
|
||||||
|
'rest_framework.authentication.TokenAuthentication',
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
DJOSER = {
|
||||||
|
'DOMAIN': 'shelfzilla.com',
|
||||||
|
'SITE_NAME': 'Shelfzilla',
|
||||||
|
'PASSWORD_RESET_CONFIRM_URL': '#/password/reset/confirm/{uid}/{token}',
|
||||||
|
'ACTIVATION_URL': '#/activate/{uid}/{token}',
|
||||||
|
'LOGIN_AFTER_ACTIVATION': True,
|
||||||
|
'SEND_ACTIVATION_EMAIL': False,
|
||||||
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ from django.conf.urls import patterns, include, url
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
||||||
from .views import MessagesView
|
from .views import MessagesView, BlockedView
|
||||||
|
|
||||||
|
|
||||||
admin.autodiscover()
|
admin.autodiscover()
|
||||||
|
@ -21,6 +21,15 @@ urlpatterns = patterns(
|
||||||
url(r'^search/', include('shelfzilla.apps.manga.urls.search')),
|
url(r'^search/', include('shelfzilla.apps.manga.urls.search')),
|
||||||
url(r'^_admin/', include('shelfzilla.apps._admin.urls')),
|
url(r'^_admin/', include('shelfzilla.apps._admin.urls')),
|
||||||
url(r'^admin/', include(admin.site.urls)),
|
url(r'^admin/', include(admin.site.urls)),
|
||||||
|
# url(r'^feedback/',
|
||||||
|
# include('object_feedback.urls', namespace="object_feedback")),
|
||||||
|
)
|
||||||
|
|
||||||
|
# API
|
||||||
|
urlpatterns += patterns(
|
||||||
|
'',
|
||||||
|
url(r'^api/v1/auth/register/', BlockedView.as_view()),
|
||||||
|
url(r'^api/v1/auth/', include('djoser.urls', namespace='api')),
|
||||||
)
|
)
|
||||||
|
|
||||||
if settings.DEBUG:
|
if settings.DEBUG:
|
||||||
|
|
|
@ -1,9 +1,15 @@
|
||||||
|
# coding: utf-8
|
||||||
|
|
||||||
|
# python
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
# django
|
||||||
from django.views.generic import View as DjangoView
|
from django.views.generic import View as DjangoView
|
||||||
from django.template import RequestContext
|
from django.template import RequestContext
|
||||||
from django.shortcuts import render_to_response
|
from django.shortcuts import render_to_response
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
|
from django.core.exceptions import PermissionDenied
|
||||||
|
|
||||||
|
|
||||||
class View(DjangoView):
|
class View(DjangoView):
|
||||||
|
@ -46,3 +52,8 @@ class MessagesView(View):
|
||||||
)
|
)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
class BlockedView(View):
|
||||||
|
def dispatch(self, *args, **kwargs):
|
||||||
|
raise PermissionDenied
|
||||||
|
|
Reference in New Issue