diff --git a/.changeset/sixty-dogs-film.md b/.changeset/sixty-dogs-film.md new file mode 100644 index 00000000000..0d627aa392a --- /dev/null +++ b/.changeset/sixty-dogs-film.md @@ -0,0 +1,5 @@ +--- +'@clerk/vue': patch +--- + +Remove `treatPendingAsSignedOut` from `useSession` and always return pending session diff --git a/packages/vue/src/composables/useSession.ts b/packages/vue/src/composables/useSession.ts index 9dd4a463bc7..e251a267183 100644 --- a/packages/vue/src/composables/useSession.ts +++ b/packages/vue/src/composables/useSession.ts @@ -1,11 +1,11 @@ -import type { PendingSessionOptions, UseSessionReturn } from '@clerk/types'; +import type { UseSessionReturn } from '@clerk/types'; import { computed } from 'vue'; import type { ToComputedRefs } from '../utils'; import { toComputedRefs } from '../utils'; import { useClerkContext } from './useClerkContext'; -type UseSession = (options?: PendingSessionOptions) => ToComputedRefs; +type UseSession = () => ToComputedRefs; /** * Returns the current [`Session`](https://clerk.com/docs/references/javascript/session) object which provides @@ -32,23 +32,20 @@ type UseSession = (options?: PendingSessionOptions) => ToComputedRefs * */ -export const useSession: UseSession = (options = {}) => { - const { sessionCtx, ...clerkContext } = useClerkContext(); +export const useSession: UseSession = () => { + const { sessionCtx, clerk } = useClerkContext(); const result = computed(() => { if (sessionCtx.value === undefined) { return { isLoaded: false, isSignedIn: undefined, session: undefined }; } - const pendingAsSignedOut = - sessionCtx.value?.status === 'pending' && - (options.treatPendingAsSignedOut ?? clerkContext.treatPendingAsSignedOut); - const isSignedOut = sessionCtx.value === null || pendingAsSignedOut; + const isSignedOut = sessionCtx.value === null; if (isSignedOut) { return { isLoaded: true, isSignedIn: false, session: null }; } - return { isLoaded: true, isSignedIn: true, session: sessionCtx.value }; + return { isLoaded: true, isSignedIn: !!clerk.value?.isSignedIn, session: sessionCtx.value }; }); return toComputedRefs(result);