feat: update authentication storage to use cookies and improve token retrieval

This commit is contained in:
estifanos
2026-07-22 09:31:10 +00:00
parent abcb538e4f
commit 75220e2b9a
6 changed files with 70 additions and 39 deletions

View File

@@ -138,8 +138,12 @@ export default function UserManagementPage() {
style.textContent = UM_OVERRIDES;
document.head.appendChild(style);
const token = localStorage.getItem('ema-backoffice-auth-token') ?? '';
const refreshToken = localStorage.getItem('ema-backoffice-refresh-token') ?? undefined;
const readCookie = (name: string) => {
const m = document.cookie.match(new RegExp('(?:^|;\\s*)' + name + '=([^;]*)'));
return m ? decodeURIComponent(m[1]) : undefined;
};
const token = readCookie('ema-backoffice-auth-token') ?? '';
const refreshToken = readCookie('ema-backoffice-refresh-token');
const session: UserManagementSessionOptions = {
initialSession: token

View File

@@ -11,7 +11,7 @@ import {
import type { AuthUser, CurrentProfile } from '@ema-platform/auth';
import { preferencesReducer } from './preferences.slice';
configureAuthStorage('ema-backoffice');
configureAuthStorage('ema-backoffice', true);
const preloadedAuth = (() => {
const token = authStorage.getToken();