update usermanagement to legacy mode

This commit is contained in:
mengstabketemaw
2026-06-18 11:25:26 +03:00
parent 3a528c9515
commit 2feaaf1ee4
13 changed files with 158 additions and 57 deletions

View File

@@ -1,5 +1,6 @@
import { useEffect, useRef, useState } from 'react';
import { useNavigate, useLocation } from 'react-router-dom';
import { authStorage } from '@ema-platform/auth';
/**
* Same-origin host for the user-management module.
@@ -18,18 +19,13 @@ import { useNavigate, useLocation } from 'react-router-dom';
*/
function readToken(): string | null {
return (
localStorage.getItem('ema-backoffice-auth-token') ??
(() => {
const escaped = 'auth-token'.replace(/([.$?*|{}()[\]\\/+^])/g, '\\$1');
const match = document.cookie.match(new RegExp('(?:^|; )' + escaped + '=([^;]*)'));
return match ? decodeURIComponent(match[1]) : null;
})()
);
const escaped = 'auth-token'.replace(/([.$?*|{}()[\]\\/+^])/g, '\\$1');
const match = document.cookie.match(new RegExp('(?:^|; )' + escaped + '=([^;]*)'));
return authStorage.getToken() ?? (match ? decodeURIComponent(match[1]) : null);
}
function readRefreshToken(): string | null {
return localStorage.getItem('ema-backoffice-refresh-token') ?? null;
return authStorage.getRefreshToken() ?? null;
}
export default function UserManagementHostPage() {