Skip to content

Commit

Permalink
pr fix
Browse files Browse the repository at this point in the history
  • Loading branch information
KlemenSpruk committed Oct 9, 2023
1 parent f7ea6ce commit 1779982
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 28 deletions.
1 change: 0 additions & 1 deletion django_project_base/account/constants.py
Original file line number Diff line number Diff line change
@@ -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-"
11 changes: 2 additions & 9 deletions django_project_base/account/rest/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,3 @@ def send_register_verification_email_notification(
user=user.pk,
).send()
cache.set(code, user, timeout=settings.CONFIRMATION_CODE_TIMEOUT)
return
1 change: 0 additions & 1 deletion django_project_base/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
Expand Down
7 changes: 3 additions & 4 deletions vue/components/notifications-editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
import {
APIConsumer,
ComponentDisplay,
ConsumerLogicApi,
FormConsumerOneShotApi, gettext,
ConsumerLogicApi, FormConsumerApiOneShot, gettext,
useActionHandler,
} from '@velis/dynamicforms';
import { onMounted, onUnmounted, ref } from 'vue';
Expand Down Expand Up @@ -50,12 +49,12 @@ const notificationLogic = ref(new ConsumerLogicApi(
notificationLogic.value.getFullDefinition();
const actionViewLicense = async (): Promise<boolean> => {
await FormConsumerOneShotApi({ url: licenseConsumerUrl, trailingSlash: licenseConsumerUrlTrailingSlash, pk: 'new' });
await FormConsumerApiOneShot({ url: licenseConsumerUrl, trailingSlash: licenseConsumerUrlTrailingSlash, pk: 'new' });
return true;
};
const actionAddNotification = async (): Promise<boolean> => {
await FormConsumerOneShotApi({
await FormConsumerApiOneShot({
url: consumerUrl,
trailingSlash: consumerTrailingSlash,
pk: 'new',
Expand Down
11 changes: 8 additions & 3 deletions vue/components/user-session/login-inline.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}, {}),
]),
Expand Down Expand Up @@ -129,7 +130,9 @@ async function validateEmailCode() {
parseErrors(err, registerWorkflowErrors);
validateEmailCode();
});
return true;
}
return false;
}
async function changeRegisterMail() {
Expand All @@ -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({
Expand Down Expand Up @@ -197,8 +201,9 @@ async function openRegistrationForm() {
}),
}),
);
await validateEmailCode();
await changeRegisterMail();
if (!await validateEmailCode()) {
await changeRegisterMail();
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions vue/components/user-session/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
ConsumerLogicApi, dfModal as dfModalApi,
dfModal, DialogSize,
DisplayMode,
FilteredActions, FormConsumerOneShotApi,
FilteredActions, FormConsumerApiOneShot,
FormPayload,
gettext,
} from '@velis/dynamicforms';
Expand Down Expand Up @@ -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 },
);

Expand Down
5 changes: 2 additions & 3 deletions vue/components/user-session/project-list.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
Action,
apiClient,
dfModal,
FormConsumerOneShotApi,
FormConsumerApiOneShot,
FormPayload,
} from '@velis/dynamicforms';
import slugify from 'slugify';
Expand Down Expand Up @@ -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) => {
Expand All @@ -60,7 +59,7 @@ async function addNewProject() {
}
return false;
};
const addProjectModal = await FormConsumerOneShotApi(
const addProjectModal = await FormConsumerApiOneShot(
{
url: '/project',
trailingSlash: false,
Expand Down
8 changes: 4 additions & 4 deletions vue/components/user-session/user-profile.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { Action, dfModal, DialogSize, FilteredActions, FormConsumerOneShotApi, gettext } from '@velis/dynamicforms';
import { Action, dfModal, DialogSize, FilteredActions, FormConsumerApiOneShot, gettext } from '@velis/dynamicforms';
import axios from 'axios';
import _ from 'lodash';
import { computed, h, onMounted, watch } from 'vue';
Expand Down Expand Up @@ -30,7 +30,7 @@ let socialConnectionsModalPromise = null as any;
const showProjectList = computed(() => (props.projectListComponent && userSession.loggedIn && display.smAndDown.value));
async function changePassword() {
await FormConsumerOneShotApi({ url: '/account/change-password/', trailingSlash: true, pk: 'new' });
await FormConsumerApiOneShot({ url: '/account/change-password/', trailingSlash: true, pk: 'new' });
}
async function checkResetPassword() {
Expand All @@ -52,7 +52,7 @@ watch(() => userSession.impersonated, () => window.location.reload());
onMounted(() => loadData());
async function showImpersonateLogin() {
await FormConsumerOneShotApi({ url: '/account/impersonate', trailingSlash: false });
await FormConsumerApiOneShot({ url: '/account/impersonate', trailingSlash: false });
await userSession.checkLogin(false);
}
Expand All @@ -62,7 +62,7 @@ async function stopImpersonation() {
}
async function userProfile() {
await FormConsumerOneShotApi({ url: '/account/profile/current', trailingSlash: false });
await FormConsumerApiOneShot({ url: '/account/profile/current', trailingSlash: false });
await userSession.checkLogin(false);
}
Expand Down

0 comments on commit 1779982

Please sign in to comment.