diff --git a/changelog/unreleased/change-auth-store b/changelog/unreleased/change-auth-store
new file mode 100644
index 00000000000..b6d1025d072
--- /dev/null
+++ b/changelog/unreleased/change-auth-store
@@ -0,0 +1,16 @@
+Change: Auth store to pinia
+
+BREAKING CHANGE for developers: Auth information is no longer stored in a vuex store but in pinia instead. You can access all the store functionality via the new `useAuthStore` composable.
+
+Note that the following composables have also been removed in favour of the pinia composable:
+
+- `useAccessToken`
+- `usePublicLinkContext`
+- `usePublicLinkPassword`
+- `usePublicLinkToken`
+- `useUserContext`
+
+For more details please see the linked PR down below.
+
+https://github.com/owncloud/web/pull/10323
+https://github.com/owncloud/web/issues/10210
diff --git a/packages/web-app-admin-settings/package.json b/packages/web-app-admin-settings/package.json
index 33120092bd8..1977c75731a 100644
--- a/packages/web-app-admin-settings/package.json
+++ b/packages/web-app-admin-settings/package.json
@@ -22,7 +22,6 @@
"pinia": "2.1.7",
"uuid": "9.0.1",
"vue-concurrency": "4.0.1",
- "vuex": "4.1.0",
"web-app-admin-settings": "workspace:*"
}
}
diff --git a/packages/web-app-admin-settings/src/views/Spaces.vue b/packages/web-app-admin-settings/src/views/Spaces.vue
index 7c8efdff6ff..6c03654fb59 100644
--- a/packages/web-app-admin-settings/src/views/Spaces.vue
+++ b/packages/web-app-admin-settings/src/views/Spaces.vue
@@ -68,7 +68,6 @@ import {
eventBus,
configurationManager,
queryItemAsString,
- useAccessToken,
useClientService,
useRouteQuery,
useSideBar,
@@ -99,7 +98,6 @@ export default defineComponent({
},
setup() {
const store = useStore()
- const accessToken = useAccessToken({ store })
const spaces = ref([])
const clientService = useClientService()
const { $gettext } = useGettext()
@@ -272,7 +270,6 @@ export default defineComponent({
sideBarActivePanel,
spaces,
loadResourcesTask,
- accessToken,
breadcrumbs,
batchActions,
selectedSpaces,
diff --git a/packages/web-app-admin-settings/src/views/Users.vue b/packages/web-app-admin-settings/src/views/Users.vue
index 1c77fcccd59..edb6069788e 100644
--- a/packages/web-app-admin-settings/src/views/Users.vue
+++ b/packages/web-app-admin-settings/src/views/Users.vue
@@ -152,7 +152,6 @@ import {
NoContentMessage,
eventBus,
queryItemAsString,
- useAccessToken,
useCapabilitySpacesMaxQuota,
useClientService,
useConfigurationManager,
@@ -199,7 +198,6 @@ export default defineComponent({
const route = useRoute()
const store = useStore()
const { showErrorMessage } = useMessages()
- const accessToken = useAccessToken({ store })
const clientService = useClientService()
const configurationManager = useConfigurationManager()
const userStore = useUserStore()
@@ -627,7 +625,6 @@ export default defineComponent({
loadResourcesTask,
loadAdditionalUserDataTask,
clientService,
- accessToken,
batchActions,
filterGroups,
filterRoles,
diff --git a/packages/web-app-files/src/components/AppBar/CreateAndUpload.vue b/packages/web-app-files/src/components/AppBar/CreateAndUpload.vue
index 1f5ba208a70..1196930cd85 100644
--- a/packages/web-app-files/src/components/AppBar/CreateAndUpload.vue
+++ b/packages/web-app-files/src/components/AppBar/CreateAndUpload.vue
@@ -204,7 +204,6 @@ import {
useCapabilityShareJailEnabled,
useCapabilitySpacesEnabled,
useStore,
- useUserContext,
useClientService
} from '@ownclouders/web-pkg'
@@ -432,7 +431,6 @@ export default defineComponent({
isSpacesGenericLocation: useActiveLocation(isLocationSpacesActive, 'files-spaces-generic'),
hasShareJail: useCapabilityShareJailEnabled(),
hasSpaces: useCapabilitySpacesEnabled(),
- isUserContext: useUserContext({ store }),
canUpload,
currentFolder,
createNewFileActions,
diff --git a/packages/web-app-files/src/components/SideBar/Actions/SpaceActions.vue b/packages/web-app-files/src/components/SideBar/Actions/SpaceActions.vue
index 5b2ba8e6cdd..34064411578 100644
--- a/packages/web-app-files/src/components/SideBar/Actions/SpaceActions.vue
+++ b/packages/web-app-files/src/components/SideBar/Actions/SpaceActions.vue
@@ -67,7 +67,7 @@ export default defineComponent({
store,
spaceImageInput
})
- const { actions: downloadArchiveActions } = useFileActionsDownloadArchive({ store })
+ const { actions: downloadArchiveActions } = useFileActionsDownloadArchive()
const actions = computed(() =>
[
diff --git a/packages/web-app-files/src/components/SideBar/Details/FileDetails.vue b/packages/web-app-files/src/components/SideBar/Details/FileDetails.vue
index e0a9335da3a..9724e0110f9 100644
--- a/packages/web-app-files/src/components/SideBar/Details/FileDetails.vue
+++ b/packages/web-app-files/src/components/SideBar/Details/FileDetails.vue
@@ -19,7 +19,7 @@
>('resource')
const space = inject[>('space')
- const isPublicLinkContext = usePublicLinkContext({ store })
const previewService = usePreviewService()
const preview = ref(undefined)
+ const authStore = useAuthStore()
+ const { publicLinkContextReady } = storeToRefs(authStore)
+
const loadData = async () => {
const calls = []
- if (unref(resource).type === 'file' && !unref(isPublicLinkContext)) {
+ if (unref(resource).type === 'file' && !unref(publicLinkContextReady)) {
calls.push(
store.dispatch('Files/loadVersions', {
client: clientService.webdav,
@@ -269,7 +275,7 @@ export default defineComponent({
return {
user,
preview,
- isPublicLinkContext,
+ publicLinkContextReady,
space,
resource,
hasTags,
@@ -309,7 +315,7 @@ export default defineComponent({
return this.showShares && this.sharedAncestor
},
showShares() {
- if (this.isPublicLinkContext) {
+ if (this.publicLinkContextReady) {
return false
}
return this.hasAnyShares
@@ -340,7 +346,7 @@ export default defineComponent({
return this.resourceSize !== '?'
},
showVersions() {
- if (this.resource.type === 'folder' || this.isPublicLinkContext) {
+ if (this.resource.type === 'folder' || this.publicLinkContextReady) {
return
}
return this.versions.length > 0
diff --git a/packages/web-app-files/src/components/SideBar/Versions/FileVersions.vue b/packages/web-app-files/src/components/SideBar/Versions/FileVersions.vue
index 63b2f9002e5..994de6341c8 100644
--- a/packages/web-app-files/src/components/SideBar/Versions/FileVersions.vue
+++ b/packages/web-app-files/src/components/SideBar/Versions/FileVersions.vue
@@ -82,7 +82,7 @@ export default defineComponent({
const store = useStore()
const clientService = useClientService()
const { current: currentLanguage } = useGettext()
- const { downloadFile } = useDownloadFile({ store, clientService })
+ const { downloadFile } = useDownloadFile({ clientService })
const space = inject][>('space')
const resource = inject][>('resource')
diff --git a/packages/web-app-files/src/components/Spaces/SpaceContextActions.vue b/packages/web-app-files/src/components/Spaces/SpaceContextActions.vue
index 76046085ffb..6f3e65a2920 100644
--- a/packages/web-app-files/src/components/Spaces/SpaceContextActions.vue
+++ b/packages/web-app-files/src/components/Spaces/SpaceContextActions.vue
@@ -65,7 +65,7 @@ export default defineComponent({
const { actions: restoreActions } = useSpaceActionsRestore({ store })
const { actions: showDetailsActions } = useFileActionsShowDetails({ store })
const { actions: showMembersActions } = useSpaceActionsShowMembers({ store })
- const { actions: downloadArchiveActions } = useFileActionsDownloadArchive({ store })
+ const { actions: downloadArchiveActions } = useFileActionsDownloadArchive()
const { actions: navigateToTrashActions } = useSpaceActionsNavigateToTrash()
const spaceImageInput: VNodeRef = ref(null)
diff --git a/packages/web-app-files/src/views/FilesDrop.vue b/packages/web-app-files/src/views/FilesDrop.vue
index 925235558b2..e77944e3f84 100644
--- a/packages/web-app-files/src/views/FilesDrop.vue
+++ b/packages/web-app-files/src/views/FilesDrop.vue
@@ -40,6 +40,7 @@ import { mapGetters } from 'vuex'
import {
createLocationPublic,
createLocationSpaces,
+ useAuthStore,
useMessages,
useThemeStore,
useUserStore
@@ -58,13 +59,11 @@ import {
import { useGettext } from 'vue3-gettext'
import {
useClientService,
- usePublicLinkToken,
useStore,
useRouter,
useRoute,
useCapabilitySpacesEnabled,
useGetMatchingSpace,
- useUserContext,
useRouteQuery,
queryItemAsString,
useUpload
@@ -94,8 +93,7 @@ export default defineComponent({
const hasSpaces = useCapabilitySpacesEnabled(store)
const authService = useAuthService()
const clientService = useClientService()
- const publicToken = usePublicLinkToken({ store })
- const isUserContext = useUserContext({ store })
+ const authStore = useAuthStore()
const { getInternalSpace } = useGetMatchingSpace()
useUpload({ uppyService })
@@ -152,7 +150,7 @@ export default defineComponent({
const resolvePublicLink = async () => {
loading.value = true
- if (unref(isUserContext) && unref(fileId)) {
+ if (authStore.userContextReady && unref(fileId)) {
try {
const path = await clientService.webdav.getPathForFileId(unref(fileId))
await resolveToInternalLocation(path)
@@ -164,7 +162,7 @@ export default defineComponent({
}
const spaces: SpaceResource[] = store.getters['runtime/spaces/spaces']
- const space = spaces.find((s) => s.driveAlias === `public/${unref(publicToken)}`)
+ const space = spaces.find((s) => s.driveAlias === `public/${authStore.publicLinkToken}`)
clientService.webdav
.listFiles(space, {}, { depth: 0 })
@@ -174,7 +172,7 @@ export default defineComponent({
if (linkRoleUploaderFolder.bitmask(false) !== sharePermissions) {
router.replace(
createLocationPublic('files-public-link', {
- params: { driveAliasAndItem: `public/${unref(publicToken)}` }
+ params: { driveAliasAndItem: `public/${authStore.publicLinkToken}` }
})
)
return
diff --git a/packages/web-app-files/src/views/spaces/DriveResolver.vue b/packages/web-app-files/src/views/spaces/DriveResolver.vue
index 66bf0107312..95b75e7ca66 100644
--- a/packages/web-app-files/src/views/spaces/DriveResolver.vue
+++ b/packages/web-app-files/src/views/spaces/DriveResolver.vue
@@ -16,6 +16,7 @@ import GenericTrash from './GenericTrash.vue'
import { computed, defineComponent, onMounted, ref, unref } from 'vue'
import {
queryItemAsString,
+ useAuthStore,
useClientService,
useConfigurationManager,
useDriveResolver,
@@ -23,8 +24,7 @@ import {
useRouteParam,
useRouteQuery,
useRouter,
- useStore,
- useUserContext
+ useStore
} from '@ownclouders/web-pkg'
import { useActiveLocation } from '@ownclouders/web-pkg'
import { createLocationSpaces, isLocationTrashActive } from '@ownclouders/web-pkg'
@@ -50,7 +50,7 @@ export default defineComponent({
},
setup() {
const store = useStore()
- const isUserContext = useUserContext({ store })
+ const authStore = useAuthStore()
const clientService = useClientService()
const router = useRouter()
const driveAliasAndItem = useRouteParam('driveAliasAndItem')
@@ -135,7 +135,7 @@ export default defineComponent({
const space = unref(resolvedDrive.space)
if (space && isPublicSpaceResource(space)) {
const isRunningOnEos = store.getters.configuration?.options?.runningOnEos
- if (unref(isUserContext) && unref(fileId) && !isRunningOnEos) {
+ if (authStore.userContextReady && unref(fileId) && !isRunningOnEos) {
try {
const path = await clientService.webdav.getPathForFileId(unref(fileId))
await resolveToInternalLocation(path)
diff --git a/packages/web-app-files/tests/unit/components/AppBar/CreateAndUpload.spec.ts b/packages/web-app-files/tests/unit/components/AppBar/CreateAndUpload.spec.ts
index 18f8a0286d2..818e967d8f0 100644
--- a/packages/web-app-files/tests/unit/components/AppBar/CreateAndUpload.spec.ts
+++ b/packages/web-app-files/tests/unit/components/AppBar/CreateAndUpload.spec.ts
@@ -18,7 +18,6 @@ import { ref } from 'vue'
jest.mock('@ownclouders/web-pkg', () => ({
...jest.requireActual('@ownclouders/web-pkg'),
- useAccessToken: jest.fn(),
useExtensionRegistry: jest.fn(),
useRequest: jest.fn(),
useFileActionsCreateNewFile: jest.fn(),
diff --git a/packages/web-app-files/tests/unit/components/FilesList/ResourceDetails.spec.ts b/packages/web-app-files/tests/unit/components/FilesList/ResourceDetails.spec.ts
index 16630c1de7b..a315619be89 100644
--- a/packages/web-app-files/tests/unit/components/FilesList/ResourceDetails.spec.ts
+++ b/packages/web-app-files/tests/unit/components/FilesList/ResourceDetails.spec.ts
@@ -15,6 +15,7 @@ import { ref } from 'vue'
jest.mock('@ownclouders/web-pkg', () => ({
...jest.requireActual('@ownclouders/web-pkg'),
+ getIndicators: jest.fn(() => []),
useRouteQuery: jest.fn(),
useFileActions: jest.fn()
}))
diff --git a/packages/web-app-files/tests/unit/components/SideBar/Details/FileDetails.spec.ts b/packages/web-app-files/tests/unit/components/SideBar/Details/FileDetails.spec.ts
index ffe0aa8212d..05833db507e 100644
--- a/packages/web-app-files/tests/unit/components/SideBar/Details/FileDetails.spec.ts
+++ b/packages/web-app-files/tests/unit/components/SideBar/Details/FileDetails.spec.ts
@@ -208,9 +208,6 @@ function createWrapper({
storeOptions.modules.runtime.modules.ancestorMetaData.getters.ancestorMetaData.mockReturnValue(
ancestorMetaData
)
- storeOptions.modules.runtime.modules.auth.getters.isPublicLinkContextReady.mockReturnValue(
- isPublicLinkContext
- )
const store = createStore(storeOptions)
const spacesLocation = createLocationSpaces('files-spaces-generic')
@@ -226,7 +223,15 @@ function createWrapper({
resource,
space: mockDeep()
},
- plugins: [...defaultPlugins({ piniaOptions: { userState: { user } } }), store],
+ plugins: [
+ ...defaultPlugins({
+ piniaOptions: {
+ userState: { user },
+ authState: { publicLinkContextReady: isPublicLinkContext }
+ }
+ }),
+ store
+ ],
mocks
}
})
diff --git a/packages/web-app-files/tests/unit/components/SideBar/TagsSelect.spec.ts b/packages/web-app-files/tests/unit/components/SideBar/TagsSelect.spec.ts
index 7a565477382..d943b0ccc95 100644
--- a/packages/web-app-files/tests/unit/components/SideBar/TagsSelect.spec.ts
+++ b/packages/web-app-files/tests/unit/components/SideBar/TagsSelect.spec.ts
@@ -11,11 +11,6 @@ import { mockDeep } from 'jest-mock-extended'
import { Resource } from '@ownclouders/web-client'
import { ClientService, eventBus, useMessages } from '@ownclouders/web-pkg'
-jest.mock('@ownclouders/web-pkg', () => ({
- ...jest.requireActual('@ownclouders/web-pkg'),
- useAccessToken: jest.fn()
-}))
-
describe('Tag Select', () => {
it('show tags input form if loaded successfully', () => {
const resource = mockDeep({ tags: [] })
diff --git a/packages/web-app-files/tests/unit/views/FilesDrop.spec.ts b/packages/web-app-files/tests/unit/views/FilesDrop.spec.ts
index 752cc85714c..1fb1ec6d4db 100644
--- a/packages/web-app-files/tests/unit/views/FilesDrop.spec.ts
+++ b/packages/web-app-files/tests/unit/views/FilesDrop.spec.ts
@@ -10,6 +10,7 @@ import {
} from 'web-test-helpers'
import { mock, mockDeep } from 'jest-mock-extended'
import { ClientService } from '@ownclouders/web-pkg'
+import { ListFilesResult } from '@ownclouders/web-client/src/webdav/listFiles'
describe('FilesDrop view', () => {
describe('different files view states', () => {
@@ -29,7 +30,7 @@ describe('FilesDrop view', () => {
function getMountedWrapper() {
const $clientService = mockDeep()
- $clientService.webdav.listFiles.mockReturnValue(undefined)
+ $clientService.webdav.listFiles.mockResolvedValue(mock())
const defaultMocks = {
...defaultComponentMocks({
currentRoute: mock({ name: 'files-common-favorites' })
diff --git a/packages/web-app-files/tests/unit/views/spaces/DriveResolver.spec.ts b/packages/web-app-files/tests/unit/views/spaces/DriveResolver.spec.ts
index a8d8c513eca..976c29b1a2e 100644
--- a/packages/web-app-files/tests/unit/views/spaces/DriveResolver.spec.ts
+++ b/packages/web-app-files/tests/unit/views/spaces/DriveResolver.spec.ts
@@ -149,16 +149,18 @@ function getMountedWrapper({
...(mocks && mocks)
}
const storeOptions = { ...defaultStoreMockOptions }
- storeOptions.modules.runtime.modules.auth.getters.isUserContextReady.mockReturnValue(
- isUserContextReady
- )
const store = createStore(storeOptions)
return {
mocks: defaultMocks,
storeOptions,
wrapper: mount(DriveResolver, {
global: {
- plugins: [...defaultPlugins(), store],
+ plugins: [
+ ...defaultPlugins({
+ piniaOptions: { authState: { userContextReady: isUserContextReady } }
+ }),
+ store
+ ],
mocks: defaultMocks,
provide: defaultMocks,
stubs: { ...defaultStubs, 'app-banner': true }
diff --git a/packages/web-app-importer/src/extensions.ts b/packages/web-app-importer/src/extensions.ts
index 688dd0f6a41..cbdce730f6d 100644
--- a/packages/web-app-importer/src/extensions.ts
+++ b/packages/web-app-importer/src/extensions.ts
@@ -1,10 +1,10 @@
import { storeToRefs } from 'pinia'
import {
useStore,
- usePublicLinkContext,
useThemeStore,
useModals,
- useUserStore
+ useUserStore,
+ useAuthStore
} from '@ownclouders/web-pkg'
import { useGettext } from 'vue3-gettext'
import { useService } from '@ownclouders/web-pkg'
@@ -24,7 +24,7 @@ export const extensions = ({ applicationConfig }: ApplicationSetupOptions) => {
const userStore = useUserStore()
const { $gettext } = useGettext()
const uppyService = useService('$uppyService')
- const publicLinkContext = usePublicLinkContext({ store })
+ const authStore = useAuthStore()
const themeStore = useThemeStore()
const { currentTheme } = storeToRefs(themeStore)
const { dispatchModal, removeModal, activeModal } = useModals()
@@ -134,7 +134,7 @@ export const extensions = ({ applicationConfig }: ApplicationSetupOptions) => {
return false
}
- if (unref(publicLinkContext)) {
+ if (authStore.publicLinkContextReady) {
return false
}
diff --git a/packages/web-app-importer/tests/unit/extensions.spec.ts b/packages/web-app-importer/tests/unit/extensions.spec.ts
index 1f9c149fb4f..b33b6c4e653 100644
--- a/packages/web-app-importer/tests/unit/extensions.spec.ts
+++ b/packages/web-app-importer/tests/unit/extensions.spec.ts
@@ -143,7 +143,6 @@ function getWrapper({
}
const storeOptions = defaultStoreMockOptions
storeOptions.modules.Files.getters.currentFolder.mockReturnValue(currentFolder)
- storeOptions.modules.runtime.modules.auth.getters.isPublicLinkContextReady.mockReturnValue(false)
const store = createStore(storeOptions)
return {
wrapper: getComposableWrapper(setup, {
diff --git a/packages/web-app-ocm/src/views/IncomingInvitations.vue b/packages/web-app-ocm/src/views/IncomingInvitations.vue
index 1017e9a3b6d..e0786dcf48b 100644
--- a/packages/web-app-ocm/src/views/IncomingInvitations.vue
+++ b/packages/web-app-ocm/src/views/IncomingInvitations.vue
@@ -61,7 +61,6 @@
]