Browse Source

Maintenance: Move account location to user current for better context.

Dominik Klein 10 months ago
parent
commit
1b552ce3c1

+ 13 - 9
app/frontend/apps/desktop/components/TwoFactor/TwoFactorConfiguration/TwoFactorConfigurationAuthenticatorApp.vue

@@ -11,8 +11,8 @@ import { useCopyToClipboard } from '#desktop/composables/useCopyToClipboard.ts'
 import { useForm } from '#shared/components/Form/useForm.ts'
 import QueryHandler from '#shared/server/apollo/handler/QueryHandler.ts'
 import MutationHandler from '#shared/server/apollo/handler/MutationHandler.ts'
-import { useAccountTwoFactorVerifyMethodConfigurationMutation } from '#shared/entities/account/graphql/mutations/accountTwoFactorVerifyMethodConfiguration.api.ts'
-import { useAccountTwoFactorInitiateMethodConfigurationQuery } from '#shared/entities/account/graphql/queries/accountTwoFactorInitiateMethodConfiguration.api.ts'
+import { useUserCurrentTwoFactorVerifyMethodConfigurationMutation } from '#shared/entities/user/current/graphql/mutations/two-factor/userCurrentTwoFactorVerifyMethodConfiguration.api.ts'
+import { useUserCurrentTwoFactorInitiateMethodConfigurationQuery } from '#shared/entities/user/current/graphql/queries/two-factor/userCurrentTwoFactorInitiateMethodConfiguration.api.ts'
 
 import UserError from '#shared/errors/UserError.ts'
 import type { FormSubmitData } from '#shared/components/Form/types.ts'
@@ -30,7 +30,7 @@ const twoFactorPlugin = twoFactorMethodLookup[props.type]
 const headerIcon = computed(() => twoFactorPlugin.icon)
 
 const initiationQuery = new QueryHandler(
-  useAccountTwoFactorInitiateMethodConfigurationQuery(
+  useUserCurrentTwoFactorInitiateMethodConfigurationQuery(
     {
       methodName: twoFactorPlugin.name,
     },
@@ -52,7 +52,7 @@ const initiationError = ref<string | null>(null)
 const { form, formSetErrors } = useForm()
 
 const mutateMethodConfiguration = new MutationHandler(
-  useAccountTwoFactorVerifyMethodConfigurationMutation(),
+  useUserCurrentTwoFactorVerifyMethodConfigurationMutation(),
 )
 
 const verifyMethodConfiguration = async (securityCode: string) => {
@@ -60,7 +60,8 @@ const verifyMethodConfiguration = async (securityCode: string) => {
     methodName: twoFactorPlugin.name,
     payload: securityCode,
     configuration: {
-      ...initiationResult.value?.accountTwoFactorInitiateMethodConfiguration,
+      ...initiationResult.value
+        ?.userCurrentTwoFactorInitiateMethodConfiguration,
     },
   })
 }
@@ -78,12 +79,15 @@ const submitForm = async ({
       message: __('Two-factor method has been configured successfully.'),
     })
 
-    if (response?.accountTwoFactorVerifyMethodConfiguration?.recoveryCodes) {
+    if (
+      response?.userCurrentTwoFactorVerifyMethodConfiguration?.recoveryCodes
+    ) {
       props.formSubmitCallback?.({
         nextState: 'recovery_codes',
         options: {
           recoveryCodes:
-            response?.accountTwoFactorVerifyMethodConfiguration?.recoveryCodes,
+            response?.userCurrentTwoFactorVerifyMethodConfiguration
+              ?.recoveryCodes,
           headerIcon: headerIcon.value,
         },
       })
@@ -150,11 +154,11 @@ const setupQrCode = async (provisioningUri: string, secret: string) => {
 }
 
 initiationQuery.onResult(({ data }) => {
-  if (data?.accountTwoFactorInitiateMethodConfiguration) {
+  if (data?.userCurrentTwoFactorInitiateMethodConfiguration) {
     // eslint-disable-next-line camelcase
     const { provisioning_uri, secret } =
       // eslint-disable-next-line no-unsafe-optional-chaining
-      data?.accountTwoFactorInitiateMethodConfiguration
+      data?.userCurrentTwoFactorInitiateMethodConfiguration
 
     setupQrCode(provisioning_uri, secret)
       .catch(() => {

+ 2 - 2
app/frontend/apps/desktop/components/TwoFactor/TwoFactorConfiguration/TwoFactorConfigurationPasswordCheck.vue

@@ -7,7 +7,7 @@ import type { FormSubmitData } from '#shared/components/Form/types.ts'
 import { useForm } from '#shared/components/Form/useForm.ts'
 import { defineFormSchema } from '#shared/form/defineFormSchema.ts'
 import { MutationHandler } from '#shared/server/apollo/handler/index.ts'
-import { useAccountPasswordCheckMutation } from '#desktop/entities/account/graphql/mutations/accountPasswordCheck.api.ts'
+import { useUserCurrentPasswordCheckMutation } from '#desktop/entities/user/current/graphql/mutations/userCurrentPasswordCheck.api.ts'
 import { useTwoFactorPlugins } from '#shared/entities/two-factor/composables/useTwoFactorPlugins.ts'
 import type { TwoFactorConfigurationComponentProps } from '../types.ts'
 
@@ -29,7 +29,7 @@ const schema = defineFormSchema([
 ])
 
 const passwordCheckMutation = new MutationHandler(
-  useAccountPasswordCheckMutation(),
+  useUserCurrentPasswordCheckMutation(),
   {
     errorNotificationMessage: __('Password could not be checked'),
   },

+ 6 - 5
app/frontend/apps/desktop/components/TwoFactor/TwoFactorConfiguration/TwoFactorConfigurationRecoveryCodes.vue

@@ -2,13 +2,14 @@
 
 <script setup lang="ts">
 import { computed, onBeforeMount, ref } from 'vue'
+import { MutationHandler } from '#shared/server/apollo/handler/index.ts'
+import UserError from '#shared/errors/UserError.ts'
+import { useUserCurrentTwoFactorRecoveryCodesGenerateMutation } from '#shared/entities/user/current/graphql/mutations/two-factor/userCurrentTwoFactorRecoveryCodesGenerate.api.ts'
+
 import CommonButton from '#desktop/components/CommonButton/CommonButton.vue'
 import CommonLoader from '#desktop/components/CommonLoader/CommonLoader.vue'
 import { usePrintMode } from '#desktop/composables/usePrintMode.ts'
 import { useCopyToClipboard } from '#desktop/composables/useCopyToClipboard.ts'
-import { MutationHandler } from '#shared/server/apollo/handler/index.ts'
-import { useAccountTwoFactorRecoveryCodesGenerateMutation } from '#shared/entities/account/graphql/mutations/accountTwoFactorRecoveryCodesGenerate.api.ts'
-import UserError from '#shared/errors/UserError.ts'
 import type { TwoFactorConfigurationComponentProps } from '../types.ts'
 
 const props = defineProps<TwoFactorConfigurationComponentProps>()
@@ -29,7 +30,7 @@ onBeforeMount(async () => {
   loading.value = true
 
   const recoveryCodesGenerate = new MutationHandler(
-    useAccountTwoFactorRecoveryCodesGenerateMutation(),
+    useUserCurrentTwoFactorRecoveryCodesGenerateMutation(),
     {
       errorNotificationMessage: __('Could not generate recovery codes'),
     },
@@ -39,7 +40,7 @@ onBeforeMount(async () => {
     .send()
     .then((data) => {
       recoveryCodes.value =
-        data?.accountTwoFactorRecoveryCodesGenerate?.recoveryCodes
+        data?.userCurrentTwoFactorRecoveryCodesGenerate?.recoveryCodes
     })
     .catch((err) => {
       if (err instanceof UserError) {

+ 13 - 12
app/frontend/apps/desktop/components/TwoFactor/TwoFactorConfiguration/TwoFactorConfigurationSecurityKeys.vue

@@ -13,10 +13,10 @@ import {
   MutationHandler,
   QueryHandler,
 } from '#shared/server/apollo/handler/index.ts'
-import { useAccountTwoFactorGetMethodConfigurationQuery } from '#shared/entities/account/graphql/mutations/accountTwoFactorGetMethodConfiguration.api.ts'
-import { useAccountTwoFactorInitiateMethodConfigurationLazyQuery } from '#shared/entities/account/graphql/queries/accountTwoFactorInitiateMethodConfiguration.api.ts'
-import { useAccountTwoFactorVerifyMethodConfigurationMutation } from '#shared/entities/account/graphql/mutations/accountTwoFactorVerifyMethodConfiguration.api.ts'
-import { useAccountTwoFactorRemoveMethodCredentialsMutation } from '#shared/entities/account/graphql/mutations/accountTwoFactorRemoveMethodCredentials.api.ts'
+import { useUserCurrentTwoFactorGetMethodConfigurationQuery } from '#shared/entities/user/current/graphql/mutations/two-factor/userCurrentTwoFactorGetMethodConfiguration.api.ts'
+import { useUserCurrentTwoFactorInitiateMethodConfigurationLazyQuery } from '#shared/entities/user/current/graphql/queries/two-factor/userCurrentTwoFactorInitiateMethodConfiguration.api.ts'
+import { useUserCurrentTwoFactorVerifyMethodConfigurationMutation } from '#shared/entities/user/current/graphql/mutations/two-factor/userCurrentTwoFactorVerifyMethodConfiguration.api.ts'
+import { useUserCurrentTwoFactorRemoveMethodCredentialsMutation } from '#shared/entities/user/current/graphql/mutations/two-factor/userCurrentTwoFactorRemoveMethodCredentials.api.ts'
 import { useNotifications } from '#shared/components/CommonNotifications/useNotifications.ts'
 import { NotificationTypes } from '#shared/components/CommonNotifications/types.ts'
 import type { ObjectLike } from '#shared/types/utils.ts'
@@ -73,7 +73,7 @@ const footerActionOptions = computed(() => {
 })
 
 const configurationQuery = new QueryHandler(
-  useAccountTwoFactorGetMethodConfigurationQuery({
+  useUserCurrentTwoFactorGetMethodConfigurationQuery({
     methodName: twoFactorPlugin.name,
   }),
   {
@@ -83,7 +83,8 @@ const configurationQuery = new QueryHandler(
 
 const configuration = computed<ObjectLike>(
   () =>
-    configurationQuery.result().value?.accountTwoFactorGetMethodConfiguration,
+    configurationQuery.result().value
+      ?.userCurrentTwoFactorGetMethodConfiguration,
 )
 
 const credentials = computed<ObjectLike[]>(
@@ -113,7 +114,7 @@ const tableItems = computed(() =>
 const { notify } = useNotifications()
 
 const removeCredentialsMutation = new MutationHandler(
-  useAccountTwoFactorRemoveMethodCredentialsMutation(),
+  useUserCurrentTwoFactorRemoveMethodCredentialsMutation(),
   {
     errorNotificationMessage: __(
       'Could not remove two-factor authentication method.',
@@ -136,7 +137,7 @@ const tableActions: MenuItem[] = [
       })
 
       if (
-        !removeCredentialsResult?.accountTwoFactorRemoveMethodCredentials
+        !removeCredentialsResult?.userCurrentTwoFactorRemoveMethodCredentials
           ?.success
       )
         return
@@ -159,7 +160,7 @@ const loading = ref(false)
 const error = ref<string | null>(null)
 
 const initiateQuery = new QueryHandler(
-  useAccountTwoFactorInitiateMethodConfigurationLazyQuery(
+  useUserCurrentTwoFactorInitiateMethodConfigurationLazyQuery(
     {
       methodName: twoFactorPlugin.name,
     },
@@ -177,7 +178,7 @@ const setupCredential = async () => {
   })
 
   const initiateData =
-    initiateQueryResult.data?.accountTwoFactorInitiateMethodConfiguration
+    initiateQueryResult.data?.userCurrentTwoFactorInitiateMethodConfiguration
 
   if (!initiateData)
     throw new Error(
@@ -192,7 +193,7 @@ const setupCredential = async () => {
 }
 
 const verifyMutation = new MutationHandler(
-  useAccountTwoFactorVerifyMethodConfigurationMutation(),
+  useUserCurrentTwoFactorVerifyMethodConfigurationMutation(),
 )
 
 const verifyCredential = async (
@@ -209,7 +210,7 @@ const verifyCredential = async (
         type: 'registration',
       },
     })
-  )?.accountTwoFactorVerifyMethodConfiguration
+  )?.userCurrentTwoFactorVerifyMethodConfiguration
 
   return verifyResult
 }

+ 2 - 2
app/frontend/apps/desktop/components/layout/LayoutSidebar/AvatarMenu/__tests__/AvaterMenuAppearanceItem.spec.ts

@@ -1,7 +1,7 @@
 // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
 
 import '#tests/graphql/builders/mocks.ts'
-import { mockAccount } from '#tests/support/mock-account.ts'
+import { mockUserCurrent } from '#tests/support/mock-userCurrent.ts'
 import { renderComponent } from '#tests/support/components/index.ts'
 
 import { EnumAppearanceTheme } from '#shared/graphql/types.ts'
@@ -11,7 +11,7 @@ import AvatarMenuAppearanceItem from '../AvatarMenuAppearanceItem.vue'
 
 describe('avatar menu apperance item', () => {
   beforeEach(() => {
-    mockAccount({
+    mockUserCurrent({
       lastname: 'Doe',
       firstname: 'John',
       preferences: {},

+ 2 - 2
app/frontend/apps/desktop/components/layout/LayoutSidebar/__tests__/LayoutSidebarFooterMenu.spec.ts

@@ -1,12 +1,12 @@
 // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
 
 import { renderComponent } from '#tests/support/components/index.ts'
-import { mockAccount } from '#tests/support/mock-account.ts'
+import { mockUserCurrent } from '#tests/support/mock-userCurrent.ts'
 import LayoutSidebarFooterMenu from '../LayoutSidebarFooterMenu.vue'
 
 describe('layout sidebar footer menu', () => {
   beforeEach(() => {
-    mockAccount({
+    mockUserCurrent({
       lastname: 'Doe',
       firstname: 'John',
     })

+ 0 - 22
app/frontend/apps/desktop/entities/account/graphql/mutations/accountPasswordCheck.api.ts

@@ -1,22 +0,0 @@
-import * as Types from '#shared/graphql/types.ts';
-
-import gql from 'graphql-tag';
-import { ErrorsFragmentDoc } from '../../../../../../shared/graphql/fragments/errors.api';
-import * as VueApolloComposable from '@vue/apollo-composable';
-import * as VueCompositionApi from 'vue';
-export type ReactiveFunction<TParam> = () => TParam;
-
-export const AccountPasswordCheckDocument = gql`
-    mutation accountPasswordCheck($password: String!) {
-  accountPasswordCheck(password: $password) {
-    success
-    errors {
-      ...errors
-    }
-  }
-}
-    ${ErrorsFragmentDoc}`;
-export function useAccountPasswordCheckMutation(options: VueApolloComposable.UseMutationOptions<Types.AccountPasswordCheckMutation, Types.AccountPasswordCheckMutationVariables> | ReactiveFunction<VueApolloComposable.UseMutationOptions<Types.AccountPasswordCheckMutation, Types.AccountPasswordCheckMutationVariables>> = {}) {
-  return VueApolloComposable.useMutation<Types.AccountPasswordCheckMutation, Types.AccountPasswordCheckMutationVariables>(AccountPasswordCheckDocument, options);
-}
-export type AccountPasswordCheckMutationCompositionFunctionResult = VueApolloComposable.UseMutationReturn<Types.AccountPasswordCheckMutation, Types.AccountPasswordCheckMutationVariables>;

+ 0 - 8
app/frontend/apps/desktop/entities/account/graphql/mutations/accountPasswordCheck.graphql

@@ -1,8 +0,0 @@
-mutation accountPasswordCheck($password: String!) {
-  accountPasswordCheck(password: $password) {
-    success
-    errors {
-      ...errors
-    }
-  }
-}

+ 0 - 12
app/frontend/apps/desktop/entities/account/graphql/mutations/accountPasswordCheck.mocks.ts

@@ -1,12 +0,0 @@
-import * as Types from '#shared/graphql/types.ts';
-
-import * as Mocks from '#tests/graphql/builders/mocks.ts'
-import * as Operations from './accountPasswordCheck.api.ts'
-
-export function mockAccountPasswordCheckMutation(defaults: Mocks.MockDefaultsValue<Types.AccountPasswordCheckMutation, Types.AccountPasswordCheckMutationVariables>) {
-  return Mocks.mockGraphQLResult(Operations.AccountPasswordCheckDocument, defaults)
-}
-
-export function waitForAccountPasswordCheckMutationCalls() {
-  return Mocks.waitForGraphQLMockCalls<Types.AccountPasswordCheckMutation>(Operations.AccountPasswordCheckDocument)
-}

+ 22 - 0
app/frontend/apps/desktop/entities/user/current/graphql/mutations/userCurrentPasswordCheck.api.ts

@@ -0,0 +1,22 @@
+import * as Types from '#shared/graphql/types.ts';
+
+import gql from 'graphql-tag';
+import { ErrorsFragmentDoc } from '../../../../../../../shared/graphql/fragments/errors.api';
+import * as VueApolloComposable from '@vue/apollo-composable';
+import * as VueCompositionApi from 'vue';
+export type ReactiveFunction<TParam> = () => TParam;
+
+export const UserCurrentPasswordCheckDocument = gql`
+    mutation userCurrentPasswordCheck($password: String!) {
+  userCurrentPasswordCheck(password: $password) {
+    success
+    errors {
+      ...errors
+    }
+  }
+}
+    ${ErrorsFragmentDoc}`;
+export function useUserCurrentPasswordCheckMutation(options: VueApolloComposable.UseMutationOptions<Types.UserCurrentPasswordCheckMutation, Types.UserCurrentPasswordCheckMutationVariables> | ReactiveFunction<VueApolloComposable.UseMutationOptions<Types.UserCurrentPasswordCheckMutation, Types.UserCurrentPasswordCheckMutationVariables>> = {}) {
+  return VueApolloComposable.useMutation<Types.UserCurrentPasswordCheckMutation, Types.UserCurrentPasswordCheckMutationVariables>(UserCurrentPasswordCheckDocument, options);
+}
+export type UserCurrentPasswordCheckMutationCompositionFunctionResult = VueApolloComposable.UseMutationReturn<Types.UserCurrentPasswordCheckMutation, Types.UserCurrentPasswordCheckMutationVariables>;

Some files were not shown because too many files changed in this diff