mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-08 22:58:17 +00:00
fix: ( backoffice ) accept phone or username in the login identifier field
This commit is contained in:
@@ -18,7 +18,8 @@ interface AuthState {
|
||||
token: string | null;
|
||||
refreshToken: string | null;
|
||||
isAuthenticated: boolean;
|
||||
login: (email: string, password: string) => Promise<void>;
|
||||
/** `identifier` may be an email, phone number or username — always sent as `email`. */
|
||||
login: (identifier: string, password: string) => Promise<void>;
|
||||
logout: () => void;
|
||||
setUser: (user: AdminUser, token: string) => void;
|
||||
initialize: () => void;
|
||||
@@ -52,9 +53,10 @@ export const useAuthStore = create<AuthState>((set, get) => ({
|
||||
}
|
||||
},
|
||||
|
||||
login: async (email: string, password: string) => {
|
||||
// Step 1: IAM login — returns token + refreshToken only
|
||||
const loginRes = await axios.post(`${API_URL}/v1/auth/login`, { email, password });
|
||||
login: async (identifier: string, password: string) => {
|
||||
// Step 1: IAM login — returns token + refreshToken only.
|
||||
// The IAM accepts an email, phone number or username in the `email` field.
|
||||
const loginRes = await axios.post(`${API_URL}/v1/auth/login`, { email: identifier, password });
|
||||
const loginData = loginRes.data?.data ?? loginRes.data;
|
||||
const { token, refreshToken } = loginData;
|
||||
if (!token) throw new Error('No token received from server');
|
||||
|
||||
Reference in New Issue
Block a user