From 65662aeb45219742119cee595a9f08223fbd68ee Mon Sep 17 00:00:00 2001 From: Keannu Bernasol Date: Wed, 27 Nov 2024 23:28:22 +0800 Subject: [PATCH] Minor fixes to registration and emails --- docmanager_backend/accounts/serializers.py | 4 ++-- docmanager_backend/config/settings.py | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/docmanager_backend/accounts/serializers.py b/docmanager_backend/accounts/serializers.py index 06b3883..d2599d1 100644 --- a/docmanager_backend/accounts/serializers.py +++ b/docmanager_backend/accounts/serializers.py @@ -46,9 +46,9 @@ class CustomUserRegistrationSerializer(serializers.ModelSerializer): raise serializers.ValidationError({"password": errors[0]}) else: raise serializers.ValidationError({"password": errors}) - if self.Meta.model.objects.filter(username=attrs.get("username")).exists(): + if self.Meta.model.objects.filter(username=attrs.get("email")).exists(): raise serializers.ValidationError( - "A user with that username already exists." + "A user with that email already exists." ) return super().validate(attrs) diff --git a/docmanager_backend/config/settings.py b/docmanager_backend/config/settings.py index 5714198..534d024 100644 --- a/docmanager_backend/config/settings.py +++ b/docmanager_backend/config/settings.py @@ -57,6 +57,8 @@ FRONTEND_PORT = get_secret("FRONTEND_PORT") # Full URLs BACKEND_URL = f"{URL_SCHEME}://{BACKEND_ADDRESS}" FRONTEND_URL = f"{URL_SCHEME}://{BACKEND_ADDRESS}" +# Used for emails +DOMAIN = f"{FRONTEND_ADDRESS}:{FRONTEND_PORT}/#" # Append port to full URLs if deployed locally if not USE_HTTPS: @@ -233,7 +235,7 @@ SIMPLE_JWT = { DJOSER = { "SEND_ACTIVATION_EMAIL": True, "SEND_CONFIRMATION_EMAIL": True, - "PASSWORD_RESET_CONFIRM_URL": "reset_password_confirm/{uid}/{token}", + "PASSWORD_RESET_CONFIRM_URL": "reset_password/confirm/{uid}/{token}", "ACTIVATION_URL": "activation/{uid}/{token}", "USER_AUTHENTICATION_RULES": ["djoser.authentication.TokenAuthenticationRule"], "SERIALIZERS": {