From 403af501066ce5c99f557037c0d22ef6be2e7420 Mon Sep 17 00:00:00 2001 From: Jelte van Boheemen Date: Thu, 21 Jul 2022 13:21:49 +0200 Subject: [PATCH 1/2] Replace django-rest-auth with dj-rest-auth --- backend/readit/serializers.py | 4 ++-- backend/readit/settings.py | 4 ++-- backend/readit/urls.py | 2 +- backend/register/urls.py | 4 ++-- backend/requirements.in | 6 +++--- backend/requirements.txt | 27 +++++++++++++++++---------- 6 files changed, 27 insertions(+), 20 deletions(-) diff --git a/backend/readit/serializers.py b/backend/readit/serializers.py index a3211ef0d..86d25501b 100644 --- a/backend/readit/serializers.py +++ b/backend/readit/serializers.py @@ -1,6 +1,6 @@ ''' -This contains some custom serializers to customize, for example, the user details django rest-auth returns after a successful login. -See https://django-rest-auth.readthedocs.io/en/latest/configuration.html for more details on the options. +This contains some custom serializers to customize, for example, the user details dj-rest-auth returns after a successful login. +See https://dj-rest-auth.readthedocs.io/en/latest/configuration.html for more details on the options. ''' from django.contrib.auth.models import User, Permission diff --git a/backend/readit/settings.py b/backend/readit/settings.py index 20b99423d..8a94e8e15 100644 --- a/backend/readit/settings.py +++ b/backend/readit/settings.py @@ -67,12 +67,12 @@ 'django.contrib.staticfiles', 'rest_framework', 'rest_framework.authtoken', - 'rest_auth', + 'dj_rest_auth', 'django.contrib.sites', 'allauth', 'allauth.account', 'allauth.socialaccount', - 'rest_auth.registration', + 'dj_rest_auth.registration', 'rdflib_django', 'corsheaders', 'rdf', diff --git a/backend/readit/urls.py b/backend/readit/urls.py index 4feba03c8..5061397fe 100644 --- a/backend/readit/urls.py +++ b/backend/readit/urls.py @@ -42,7 +42,7 @@ 'rest_framework.urls', namespace='rest_framework', )), - path('rest-auth/', include('rest_auth.urls')), + path('rest-auth/', include('dj_rest_auth.urls')), path('rest-auth/registration/', include('register.urls')), re_path(r'proxy/(?P.*)', decode_and_proxy), path(VOCAB_ROUTE, include('vocab.urls')), diff --git a/backend/register/urls.py b/backend/register/urls.py index 2452729fb..a09474140 100644 --- a/backend/register/urls.py +++ b/backend/register/urls.py @@ -5,12 +5,12 @@ """ from django.urls import path, re_path, include from django.views.generic import TemplateView -from rest_auth.registration.views import VerifyEmailView, RegisterView +from dj_rest_auth.registration.views import VerifyEmailView, RegisterView from allauth.account.views import confirm_email from .views import null_view urlpatterns = [ re_path(r'^account-email-verification-sent/', null_view, name='account_email_verification_sent'), re_path(r'^account-confirm-email/', null_view, name='account_confirm_email'), - path('', include('rest_auth.registration.urls')), + path('', include('dj_rest_auth.registration.urls')), ] diff --git a/backend/requirements.in b/backend/requirements.in index 3a56f63f5..e1e206bbf 100644 --- a/backend/requirements.in +++ b/backend/requirements.in @@ -1,11 +1,11 @@ celery django>=3.2,<4 -djangorestframework -django-rest-auth[with_social] defusedxml<0.6.0 +dj-rest-auth[with_social] +django-cors-headers django-livereload-server django-proxy -django-cors-headers +djangorestframework elasticsearch rdflib>6 rdflib-django3 diff --git a/backend/requirements.txt b/backend/requirements.txt index ec03895f5..a447f6ccc 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -24,6 +24,8 @@ certifi==2019.6.16 # via # elasticsearch # requests +cffi==1.15.1 + # via cryptography charset-normalizer==2.0.12 # via requests click==8.1.3 @@ -38,33 +40,35 @@ click-plugins==1.1.1 # via celery click-repl==0.2.0 # via celery +cryptography==37.0.4 + # via pyjwt defusedxml==0.5.0 # via # -r requirements.in # python3-openid +dj-rest-auth[with_social]==2.2.5 + # via -r requirements.in django==3.2.14 # via # -r requirements.in + # dj-rest-auth # django-allauth # django-cors-headers # django-livereload-server - # django-rest-auth # djangorestframework # rdflib-django3 -django-allauth==0.41.0 - # via django-rest-auth +django-allauth==0.50.0 + # via dj-rest-auth django-cors-headers==3.11.0 # via -r requirements.in django-livereload-server==0.4 # via -r requirements.in django-proxy==1.2.1 # via -r requirements.in -django-rest-auth[with_social]==0.9.5 - # via -r requirements.in djangorestframework==3.13.1 # via # -r requirements.in - # django-rest-auth + # dj-rest-auth elasticsearch==7.17.4 # via -r requirements.in execnet==1.7.1 @@ -77,7 +81,7 @@ isodate==0.6.0 # via rdflib kombu==5.2.4 # via celery -oauthlib==3.1.0 +oauthlib==3.2.0 # via requests-oauthlib packaging==19.1 # via pytest @@ -89,6 +93,10 @@ psycopg2==2.8.4 # via -r requirements.in py==1.11.0 # via pytest +pycparser==2.21 + # via cffi +pyjwt[crypto]==2.4.0 + # via django-allauth pyparsing==2.4.2 # via # packaging @@ -105,7 +113,7 @@ pytest-forked==1.0.2 # via pytest-xdist pytest-xdist==1.29.0 # via -r requirements.in -python3-openid==3.1.0 +python3-openid==3.2.0 # via django-allauth pytz==2019.2 # via @@ -124,13 +132,12 @@ requests==2.28.0 # django-allauth # django-proxy # requests-oauthlib -requests-oauthlib==1.3.0 +requests-oauthlib==1.3.1 # via django-allauth six==1.12.0 # via # click-repl # django-livereload-server - # django-rest-auth # isodate # packaging # pytest-xdist From bdb63b39867f4dd295e3e9680aac967d5b56ddd6 Mon Sep 17 00:00:00 2001 From: Jelte van Boheemen Date: Thu, 21 Jul 2022 13:28:25 +0200 Subject: [PATCH 2/2] Fix registration form password validation --- frontend/src/registration/registration-view.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/frontend/src/registration/registration-view.ts b/frontend/src/registration/registration-view.ts index 5d976dc81..c2ae2b505 100644 --- a/frontend/src/registration/registration-view.ts +++ b/frontend/src/registration/registration-view.ts @@ -9,17 +9,17 @@ export default class RegistrationFormView extends View { render(): this { this.$el.html(this.template(this)); - this.$('form').validate({ + this.$("form").validate({ errorClass: "help is-danger", rules: { email: { required: true, - email: true + email: true, + }, + password1: "required", + password2: { + equalTo: "#password", }, - password: "required", - password_again: { - equalTo: "#password" - } }, }); return this;