diff --git a/CHANGELOG.md b/CHANGELOG.md index f9fb8127..4dd775d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ - fixed password change token expiry computation - fixed register serializer to allow null values of url_format and email_format +- register email subject in settings ### Removed diff --git a/concrete_datastore/api/v1/serializers.py b/concrete_datastore/api/v1/serializers.py index 2dcff7c4..9e955d0a 100644 --- a/concrete_datastore/api/v1/serializers.py +++ b/concrete_datastore/api/v1/serializers.py @@ -64,7 +64,11 @@ class RegisterSerializer(serializers.Serializer): password1 = serializers.CharField(required=False, allow_null=True) password2 = serializers.CharField(required=False, allow_null=True) email_format = serializers.CharField(required=False, allow_null=True) - url_format = serializers.CharField(required=False, allow_null=True) + url_format = serializers.CharField( + required=False, + allow_null=True, + default=settings.DEFAULT_REGISTER_URL_FORMAT, + ) class Meta: fields = ( @@ -77,20 +81,24 @@ class Meta: def validate_url_format(self, value): if value is None: - return '/#/set-password/{token}/{email}/' + return settings.DEFAULT_REGISTER_URL_FORMAT return value class ResetPasswordSerializer(serializers.Serializer): email = serializers.EmailField() - url_format = serializers.CharField(required=False, allow_null=True) + url_format = serializers.CharField( + required=False, + allow_null=True, + default=settings.DEFAULT_RESET_PASSWORD_URL_FORMAT, + ) class Meta: fields = ("email", "url_format") def validate_url_format(self, value): if value is None: - return '/#/reset-password/{token}/{email}/' + return settings.DEFAULT_RESET_PASSWORD_URL_FORMAT return value diff --git a/concrete_datastore/api/v1/views.py b/concrete_datastore/api/v1/views.py index a016cfff..6e809d2d 100644 --- a/concrete_datastore/api/v1/views.py +++ b/concrete_datastore/api/v1/views.py @@ -984,7 +984,7 @@ def create_user(self, request, serializer, divider=None): confirmation.send_link(body=email_body) else: Email.objects.create( - subject='Set password', + subject=settings.REGISTER_EMAIL_SUBJECT, resource_status='to-send', resource_message='', body=email_body, diff --git a/concrete_datastore/settings/base.py b/concrete_datastore/settings/base.py index 75abb79d..600a8a9b 100644 --- a/concrete_datastore/settings/base.py +++ b/concrete_datastore/settings/base.py @@ -95,6 +95,8 @@ """ # nosec +DEFAULT_RESET_PASSWORD_URL_FORMAT = '/#/reset-password/{token}/{email}/' + AUTH_CONFIRM_RESET_PASSWORD_EMAIL_BODY = """ @@ -447,6 +449,10 @@ ALLOW_SEND_EMAIL_ON_REGISTER = True +REGISTER_EMAIL_SUBJECT = "Account created" + +DEFAULT_REGISTER_URL_FORMAT = '/#/set-password/{token}/{email}/' + DEFAULT_REGISTER_EMAIL_FORMAT = """ diff --git a/development/settings.py b/development/settings.py index 8d32407b..123fd06f 100644 --- a/development/settings.py +++ b/development/settings.py @@ -63,10 +63,10 @@ DISABLED_MODELS = () -EMAIL_HOST = os.environ.get("EMAIL_HOST", 'localhost') +EMAIL_HOST = os.environ.get("EMAIL_HOST", '') EMAIL_HOST_USER = os.environ.get("EMAIL_HOST_USER", '') EMAIL_HOST_PASSWORD = os.environ.get("EMAIL_HOST_PASSWORD", '') -EMAIL_PORT = os.environ.get("EMAIL_PORT", 1025) +EMAIL_PORT = os.environ.get("EMAIL_PORT", 587) EMAIL_USE_TLS = True EMAIL_USE_SSL = False EMAIL_TIMEOUT = None