diff --git a/legalconsenthub-backend/api/legalconsenthub.yml b/legalconsenthub-backend/api/legalconsenthub.yml index 8ba9b2b..dc4b1c3 100644 --- a/legalconsenthub-backend/api/legalconsenthub.yml +++ b/legalconsenthub-backend/api/legalconsenthub.yml @@ -1130,12 +1130,9 @@ components: type: object required: - message - - createdBy properties: message: type: string - createdBy: - $ref: "#/components/schemas/UserDto" PagedCommentDto: type: object diff --git a/legalconsenthub/composables/comment/useComment.ts b/legalconsenthub/composables/comment/useComment.ts index c5403ef..99a27a3 100644 --- a/legalconsenthub/composables/comment/useComment.ts +++ b/legalconsenthub/composables/comment/useComment.ts @@ -3,15 +3,14 @@ import type { CreateCommentDto, CommentDto } from '~/.api-client' export function useComment(applicationFormId: string) { const commentStore = useCommentStore() const { createComment, updateComment } = commentStore - const { userDto } = useAuth() + const { user } = useAuth() const isEditingComment = ref(false) const currentEditedComment = ref(null) const commentTextAreaValue = ref('') async function submitComment(formElementId: string) { const newCommentDto: CreateCommentDto = { - message: commentTextAreaValue.value, - createdBy: userDto.value + message: commentTextAreaValue.value } try { await createComment(applicationFormId, formElementId, newCommentDto) @@ -51,7 +50,7 @@ export function useComment(applicationFormId: string) { } function isCommentByUser(comment: CommentDto) { - return comment.createdBy.id === userDto.value.id + return comment.createdBy.id === user.value?.id } return { diff --git a/legalconsenthub/composables/useAuth.ts b/legalconsenthub/composables/useAuth.ts index e440448..3660e3f 100644 --- a/legalconsenthub/composables/useAuth.ts +++ b/legalconsenthub/composables/useAuth.ts @@ -50,6 +50,11 @@ export function useAuth() { fetchOptions: { headers }, + user: { + deleteUser: { + enabled: true + } + }, plugins: [ organizationClient({ // Pass the same access control instance and roles to client @@ -158,25 +163,19 @@ export function useAuth() { return res } - const userDto = computed(() => ({ - id: user.value?.id ?? '', - name: user.value?.name ?? 'Unknown' - })) - return { session, user, - userDto, loggedIn: computed(() => !!session.value), signIn: client.signIn, signUp: client.signUp, + deleteUser: client.deleteUser, signOut, organization: client.organization, organizations, selectedOrganization, options, fetchSession, - fetchJwtAndOrganizations, client, jwt, isPublicRoute, diff --git a/legalconsenthub/composables/useBetterAuth.ts b/legalconsenthub/composables/useBetterAuth.ts index ba5b7a4..fc725ba 100644 --- a/legalconsenthub/composables/useBetterAuth.ts +++ b/legalconsenthub/composables/useBetterAuth.ts @@ -15,7 +15,7 @@ export function useBetterAuth() { return Promise.reject() } - await organization.create( + return await organization.create( { name, slug, logo }, { onSuccess: () => { diff --git a/legalconsenthub/pages/create.vue b/legalconsenthub/pages/create.vue index 4bb633d..cccdece 100644 --- a/legalconsenthub/pages/create.vue +++ b/legalconsenthub/pages/create.vue @@ -86,7 +86,7 @@ import type { StepperItem } from '@nuxt/ui' const { getAllApplicationFormTemplates } = useApplicationFormTemplate() const { createApplicationForm, submitApplicationForm } = useApplicationForm() const { validateFormElements, getHighestComplianceStatus } = useApplicationFormValidator() -const { userDto, selectedOrganization } = useAuth() +const { selectedOrganization } = useAuth() const { canCreateApplicationForm, getCurrentRoleInfo } = usePermissions() const toast = useToast() @@ -196,8 +196,6 @@ async function prepareAndCreateApplicationForm() { return null } - applicationFormTemplate.value.createdBy = userDto.value - applicationFormTemplate.value.lastModifiedBy = userDto.value applicationFormTemplate.value.organizationId = selectedOrganization.value?.id ?? '' return await createApplicationForm(applicationFormTemplate.value) diff --git a/legalconsenthub/pages/signup.vue b/legalconsenthub/pages/signup.vue index c43e534..4898f46 100644 --- a/legalconsenthub/pages/signup.vue +++ b/legalconsenthub/pages/signup.vue @@ -27,7 +27,7 @@ definePageMeta({ layout: 'auth' }) useSeoMeta({ title: 'Sign up' }) const toast = useToast() -const { signUp } = useAuth() +const { signUp, deleteUser } = useAuth() const { createUser } = useUser() const fields = [ @@ -116,8 +116,9 @@ function onSubmit(payload: FormSubmitEvent) { await navigateTo('/') }, - onError: (ctx) => { + onError: async (ctx) => { console.log(ctx.error.message) + await deleteUser({ callbackURL: '/signup' }) useToast().add({ title: 'Fehler bei der Registrierung', description: ctx.error.message,