Implement djoser

This commit is contained in:
michigg 2018-03-31 22:59:26 +02:00
parent f4dd21440f
commit c6e0418a34
3 changed files with 25 additions and 3 deletions

View File

@ -43,6 +43,7 @@ INSTALLED_APPS = [
'apps.registration', 'apps.registration',
'rest_framework', 'rest_framework',
'rest_framework.authtoken', 'rest_framework.authtoken',
'djoser',
'analytical', 'analytical',
'corsheaders', 'corsheaders',
] ]
@ -50,9 +51,14 @@ INSTALLED_APPS = [
SITE_ID = 1 SITE_ID = 1
REST_FRAMEWORK = { REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.BasicAuthentication',
'rest_framework.authentication.SessionAuthentication',
'rest_framework.authentication.TokenAuthentication',
),
'DEFAULT_PERMISSION_CLASSES': [ 'DEFAULT_PERMISSION_CLASSES': [
'rest_framework.permissions.IsAuthenticated', 'rest_framework.permissions.IsAuthenticated',
'rest_framework.authentication.TokenAuthentication' 'rest_framework.authentication.TokenAuthentication',
], ],
} }
MIDDLEWARE = [ MIDDLEWARE = [
@ -232,3 +238,17 @@ CORS_ORIGIN_ALLOW_ALL = False
CORS_ORIGIN_WHITELIST = ( CORS_ORIGIN_WHITELIST = (
'localhost:3000', 'localhost:3000',
) )
DJOSER = {
'SEND_ACTIVATION_EMAIL': True,
'PASSWORD_RESET_CONFIRM_URL': '/#/password-reset/confirm/{uid}/{token}',
'PASSWORD_RESET_SHOW_EMAIL_NOT_FOUND': True,
# re_new_password
'PASSWORD_RESET_CONFIRM_RETYPE': True,
'SET_PASSWORD_RETYPE': True,
'ACTIVATION_URL': '/#/activation/{uid}/{token}',
}
# TODO: env vars
DOMAIN = 'localhost:3000'
SITE_NAME = 'BaStA'

View File

@ -13,6 +13,7 @@ Including another URLconf
1. Import the include() function: from django.conf.urls import url, include 1. Import the include() function: from django.conf.urls import url, include
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
""" """
from core import views from core import views
from django.conf.urls import url, include from django.conf.urls import url, include
from django.contrib import admin from django.contrib import admin
@ -59,5 +60,6 @@ urlpatterns = [
# -- Third Party APIs # -- Third Party APIs
url(r'^api/auth/', include('rest_framework.urls', namespace='rest_framework')), url(r'^api/auth/', include('rest_framework.urls', namespace='rest_framework')),
url(r'^api/token-auth/', token_auth_views.obtain_auth_token), url(r'^api/token-auth/', include('djoser.urls')),
url(r'^api/token-auth/', include('djoser.urls.authtoken')),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

View File

@ -11,4 +11,4 @@ beautifulsoup4==4.6.0
xmltodict==0.11.0 xmltodict==0.11.0
coverage==3.6 coverage==3.6
django-cors-headers django-cors-headers
djoser==1.1.5