From 5af19ed4c3cb306f5d67b84e57f53c210df5ade4 Mon Sep 17 00:00:00 2001 From: clonbg Date: Wed, 22 Feb 2023 12:38:33 +0100 Subject: [PATCH] token authentication --- listaCompra/settings.py | 11 +++++++++++ listaCompra/urls.py | 5 +++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/listaCompra/settings.py b/listaCompra/settings.py index 3427772..7594b4b 100644 --- a/listaCompra/settings.py +++ b/listaCompra/settings.py @@ -31,9 +31,20 @@ INSTALLED_APPS = [ 'compra.apps.CompraConfig', # Terceras partes 'rest_framework', + 'rest_framework.authtoken', 'djoser' ] +REST_FRAMEWORK = { + 'DEFAULT_AUTHENTICATION_CLASSES': + ('rest_framework.authentication.TokenAuthentication', ), + 'DEFAULT_PERMISSION_CLASSES': [ + 'rest_framework.permissions.IsAuthenticated', + ] +} +# configure Djoser +DJOSER = {"USER_ID_FIELD": "email"} + AUTH_USER_MODEL = 'authentication.User' MIDDLEWARE = [ diff --git a/listaCompra/urls.py b/listaCompra/urls.py index 4696cf2..9fddf07 100644 --- a/listaCompra/urls.py +++ b/listaCompra/urls.py @@ -3,10 +3,11 @@ from django.urls import path, include urlpatterns = [ path('admin/', admin.site.urls), - path('auth/', include('authentication.urls')), + path('users/', include('authentication.urls')), path('comparte/', include('comparte.urls')), path('compra/', include('compra.urls')), path('item/', include('item.urls')), path('lista/', include('lista.urls')), - path('token/', include('djoser.urls')), + path('auth/', include('djoser.urls')), + path('auth/', include('djoser.urls.authtoken')) ]