From 17799828149a684b5e44ca0c5703b6c225a63c9d Mon Sep 17 00:00:00 2001 From: KlemenSpruk Date: Mon, 9 Oct 2023 14:34:36 +0200 Subject: [PATCH] pr fix --- django_project_base/account/constants.py | 1 - django_project_base/account/rest/account.py | 11 ++--------- .../account/service/register_user_service.py | 1 - django_project_base/settings.py | 1 - vue/components/notifications-editor.vue | 7 +++---- vue/components/user-session/login-inline.vue | 11 ++++++++--- vue/components/user-session/login.ts | 4 ++-- vue/components/user-session/project-list.vue | 5 ++--- vue/components/user-session/user-profile.vue | 8 ++++---- 9 files changed, 21 insertions(+), 28 deletions(-) diff --git a/django_project_base/account/constants.py b/django_project_base/account/constants.py index 573fe593..7cf0533f 100644 --- a/django_project_base/account/constants.py +++ b/django_project_base/account/constants.py @@ -1,4 +1,3 @@ ACCOUNT_APP_ID = "django_project_base.account" MERGE_USERS_QS_CK = f"merge-users-list-%d" # noqa: F541 RESET_USER_PASSWORD_VERIFICATION_CODE = "reset-user-password-ver-identifier-" -REGISTER_USER_ACCOUNT_VERIFICATION_CODE = "register-user-account-verification-code-" diff --git a/django_project_base/account/rest/account.py b/django_project_base/account/rest/account.py index e69f018c..220cf089 100644 --- a/django_project_base/account/rest/account.py +++ b/django_project_base/account/rest/account.py @@ -184,15 +184,7 @@ class SuperUserChangePasswordSerializer(ChangePasswordSerializer): return response -class VerifyRegistrationSerializer(serializers.Serializer): - user_id = fields.CharField(required=True) - timestamp = fields.IntegerField(required=True) - signature = fields.CharField(required=True) - - class VerifyRegistrationViewSet(viewsets.ViewSet): - serializer_class = VerifyRegistrationSerializer() - @extend_schema( description="Verify registration with signature. The endpoint will generate an e-mail with a confirmation URL " "which the user should GET to confirm the account.", @@ -245,7 +237,8 @@ def verify_registration_change_email(self, request: Request) -> Response: validate_email(email) except DjangoValidationError: raise ValidationError(dict(email=[_("Email invalid")])) - get_user_model().objects.filter(pk=user.pk).update(email=email) + user.email = email + user.save(update_fields=["email"]) if registration_settings.REGISTER_VERIFICATION_ENABLED: registration_settings.REGISTER_VERIFICATION_EMAIL_SENDER(request=request, user=user) return Response() diff --git a/django_project_base/account/service/register_user_service.py b/django_project_base/account/service/register_user_service.py index 46646e54..93d1095e 100644 --- a/django_project_base/account/service/register_user_service.py +++ b/django_project_base/account/service/register_user_service.py @@ -28,4 +28,3 @@ def send_register_verification_email_notification( user=user.pk, ).send() cache.set(code, user, timeout=settings.CONFIRMATION_CODE_TIMEOUT) - return diff --git a/django_project_base/settings.py b/django_project_base/settings.py index 56d37183..80f2ed60 100644 --- a/django_project_base/settings.py +++ b/django_project_base/settings.py @@ -36,7 +36,6 @@ "RESET_PASSWORD_VERIFICATION_ENABLED": True, "RESET_PASSWORD_SERIALIZER_PASSWORD_CONFIRM": True, "SEND_RESET_PASSWORD_LINK_USER_FINDER": "django_project_base.account.service.reset_password_email_service.find_user_by_send_reset_password_link_data", # noqa: E501 - # todo dod "REGISTER_VERIFICATION_ENABLED": True, "REGISTER_VERIFICATION_EMAIL_SENDER": "django_project_base.account.service.register_user_service.send_register_verification_email_notification", # noqa: E501 }, diff --git a/vue/components/notifications-editor.vue b/vue/components/notifications-editor.vue index 45a0fba2..fd79ca88 100644 --- a/vue/components/notifications-editor.vue +++ b/vue/components/notifications-editor.vue @@ -2,8 +2,7 @@ import { APIConsumer, ComponentDisplay, - ConsumerLogicApi, - FormConsumerOneShotApi, gettext, + ConsumerLogicApi, FormConsumerApiOneShot, gettext, useActionHandler, } from '@velis/dynamicforms'; import { onMounted, onUnmounted, ref } from 'vue'; @@ -50,12 +49,12 @@ const notificationLogic = ref(new ConsumerLogicApi( notificationLogic.value.getFullDefinition(); const actionViewLicense = async (): Promise => { - await FormConsumerOneShotApi({ url: licenseConsumerUrl, trailingSlash: licenseConsumerUrlTrailingSlash, pk: 'new' }); + await FormConsumerApiOneShot({ url: licenseConsumerUrl, trailingSlash: licenseConsumerUrlTrailingSlash, pk: 'new' }); return true; }; const actionAddNotification = async (): Promise => { - await FormConsumerOneShotApi({ + await FormConsumerApiOneShot({ url: consumerUrl, trailingSlash: consumerTrailingSlash, pk: 'new', diff --git a/vue/components/user-session/login-inline.vue b/vue/components/user-session/login-inline.vue index 7c135047..7fe8b814 100644 --- a/vue/components/user-session/login-inline.vue +++ b/vue/components/user-session/login-inline.vue @@ -94,6 +94,7 @@ async function validateEmailCode() { type: 'text', id: 'new-account-confirmation-code', class: 'w-20 mb-2 p-1 justify-center rounded border-lightgray', + style: 'padding: 0.1em;', placeholder: registerWorkflowErrors.code ? registerWorkflowErrors.code : null, }, {}), ]), @@ -129,7 +130,9 @@ async function validateEmailCode() { parseErrors(err, registerWorkflowErrors); validateEmailCode(); }); + return true; } + return false; } async function changeRegisterMail() { @@ -150,7 +153,8 @@ async function changeRegisterMail() { type: 'text', id: 'new-account-different-email', placeholder: registerWorkflowErrors.email ? registerWorkflowErrors.email : null, - class: 'w-80 mb-2 p-1 justify-center rounded border-lightgray', + class: 'w-100 mb-2 p-1 justify-center rounded border-lightgray', + style: 'padding: 0.1em;', }, {}), ]), ], new FilteredActions({ @@ -197,8 +201,9 @@ async function openRegistrationForm() { }), }), ); - await validateEmailCode(); - await changeRegisterMail(); + if (!await validateEmailCode()) { + await changeRegisterMail(); + } } } diff --git a/vue/components/user-session/login.ts b/vue/components/user-session/login.ts index 209d7eff..224691e0 100644 --- a/vue/components/user-session/login.ts +++ b/vue/components/user-session/login.ts @@ -3,7 +3,7 @@ import { ConsumerLogicApi, dfModal as dfModalApi, dfModal, DialogSize, DisplayMode, - FilteredActions, FormConsumerOneShotApi, + FilteredActions, FormConsumerApiOneShot, FormPayload, gettext, } from '@velis/dynamicforms'; @@ -221,7 +221,7 @@ function useLogin() { socialAuth.value = formDef.payload.social_auth_providers; } - const openRegistration = async () => FormConsumerOneShotApi( + const openRegistration = async () => FormConsumerApiOneShot( { url: '/account/profile/register', trailingSlash: false }, ); diff --git a/vue/components/user-session/project-list.vue b/vue/components/user-session/project-list.vue index 7596fc02..f3cddc19 100644 --- a/vue/components/user-session/project-list.vue +++ b/vue/components/user-session/project-list.vue @@ -3,7 +3,7 @@ import { Action, apiClient, dfModal, - FormConsumerOneShotApi, + FormConsumerApiOneShot, FormPayload, } from '@velis/dynamicforms'; import slugify from 'slugify'; @@ -46,7 +46,6 @@ async function loadData() { } async function addNewProject() { - // const addProjectModal = await FormConsumerOneShotApi({ url: '/project', trailingSlash: false, pk: 'new' }); let slugChanged = false; let ignoreSlugChange = false; const valueChangedHandler = (action: Action, payload: FormPayload, context: any) => { @@ -60,7 +59,7 @@ async function addNewProject() { } return false; }; - const addProjectModal = await FormConsumerOneShotApi( + const addProjectModal = await FormConsumerApiOneShot( { url: '/project', trailingSlash: false, diff --git a/vue/components/user-session/user-profile.vue b/vue/components/user-session/user-profile.vue index a5012236..e64b8f50 100644 --- a/vue/components/user-session/user-profile.vue +++ b/vue/components/user-session/user-profile.vue @@ -1,5 +1,5 @@