[backend + frontend]: Добавлена базовая регистрация

This commit is contained in:
2022-09-12 23:57:40 +03:00
parent 818bb9db81
commit ede65b0147
21 changed files with 198 additions and 29 deletions

View File

@@ -1,10 +1,35 @@
asgiref==3.5.2
backports.zoneinfo==0.2.1
certifi==2022.6.15.1
cffi==1.15.1
charset-normalizer==2.1.1
coreapi==2.3.3
coreschema==0.0.4
cryptography==38.0.1
defusedxml==0.7.1
Django==4.1.1
django-cors-headers==3.13.0
django-filter==22.1
django-templated-mail==1.1.1
djangorestframework==3.13.1
djangorestframework-gis==1.0
djangorestframework-simplejwt==4.8.0
djoser==2.1.0
idna==3.3
itypes==1.2.0
Jinja2==3.1.2
MarkupSafe==2.1.1
oauthlib==3.2.1
psycopg2==2.9.3
pycparser==2.21
PyJWT==2.4.0
python3-openid==3.2.0
pytz==2022.2.1
requests==2.28.1
requests-oauthlib==1.3.1
six==1.16.0
social-auth-app-django==4.0.0
social-auth-core==4.3.0
sqlparse==0.4.2
uritemplate==4.1.1
urllib3==1.26.12

View File

@@ -4,5 +4,5 @@ from django.utils.translation import gettext_lazy
class AuthConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "authentication"
verbose_name = gettext_lazy("authentication")
name = "accounts"
verbose_name = gettext_lazy("accounts")

View File

@@ -0,0 +1,14 @@
from django.urls import path
from django.urls import include
from accounts.views import CustomTokenObtainPairView
urlpatterns = [
path("", include("djoser.urls")),
path(
"auth/jwt/create",
CustomTokenObtainPairView.as_view(),
name="custom_token_obtain_pair",
),
path("auth/", include("djoser.urls.jwt")),
]

View File

@@ -0,0 +1,13 @@
from rest_framework_simplejwt.serializers import TokenObtainPairSerializer
from rest_framework_simplejwt.views import TokenObtainPairView
class CustomTokenObtainPairSerializer(TokenObtainPairSerializer):
def validate(self, attrs):
data = super().validate(attrs)
data["username"] = self.user.username
return data
class CustomTokenObtainPairView(TokenObtainPairView):
serializer_class = CustomTokenObtainPairSerializer

View File

@@ -1,9 +0,0 @@
from django.urls import path
from rest_framework_simplejwt.views import TokenObtainPairView
from rest_framework_simplejwt.views import TokenRefreshView
urlpatterns = [
path("token", TokenObtainPairView.as_view(), name="token_obtain_pair"),
path("token/refresh", TokenRefreshView.as_view(), name="token_refresh"),
]

View File

@@ -1,3 +0,0 @@
from django.shortcuts import render
# Create your views here.

View File

@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-09-10 14:48+0300\n"
"POT-Creation-Date: 2022-09-12 23:55+0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -20,6 +20,10 @@ msgstr ""
"%10<=4 && (n%100<12 || n%100>14) ? 1 : n%10==0 || (n%10>=5 && n%10<=9) || (n"
"%100>=11 && n%100<=14)? 2 : 3);\n"
#: accounts/apps.py:8
msgid "accounts"
msgstr "аккаунты"
#: facilities/apps.py:8 facilities/models.py:18
msgid "facilities"
msgstr "заведения"

View File

@@ -43,11 +43,11 @@ INSTALLED_APPS = [
"django.contrib.messages",
"django.contrib.staticfiles",
"django.contrib.gis",
"djoser",
"rest_framework",
"rest_framework_simplejwt",
"rest_framework_gis",
"corsheaders",
"authentication",
"accounts",
"facilities",
]
@@ -128,9 +128,12 @@ STATIC_URL = "static/"
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
REST_FRAMEWORK = {
"DEFAULT_AUTHENTICATION_CLASSES": (
"rest_framework_simplejwt.authentication.JWTAuthentication",
)
),
}
SIMPLE_JWT = {
"AUTH_HEADER_TYPES": ("JWT",),
}

View File

@@ -11,3 +11,7 @@ DATABASES = {
"PORT": "5432",
}
}
CORS_ALLOWED_ORIGINS = [
"http://localhost:8080",
]

View File

@@ -19,6 +19,6 @@ from django.urls import include
urlpatterns = [
path("admin/", admin.site.urls),
path("api/auth/", include("authentication.urls")),
path("api/accounts/", include("accounts.urls")),
path("api/facilities/", include("facilities.urls")),
]