Skip to content

Commit 8a2f551

Browse files
committed
fix: use localStorage for OIDC tokens to prevent multi-tab session loss
oidc-client-ts defaults to sessionStorage which is per-tab, causing login state to be lost when multiple tabs are open since the Pinia auth store persists in shared localStorage.
1 parent d01f62a commit 8a2f551

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/services/auth.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { type User, UserManager, type UserManagerSettings } from 'oidc-client-ts';
1+
import { type User, UserManager, type UserManagerSettings, WebStorageStateStore } from 'oidc-client-ts';
22

33
import { api, ui } from '@/configuration';
44
import { useAuthStore } from '@/stores/auth';
@@ -40,6 +40,7 @@ const getUserManager = async () => {
4040
redirect_uri: `${window.location.origin}${prefix}/auth/callback`,
4141
scope: 'public openid profile email',
4242
response_type: 'code',
43+
userStore: new WebStorageStateStore({ store: window.localStorage }),
4344
};
4445

4546
userManager = new UserManager(config);

0 commit comments

Comments
 (0)