From da2949279897597dbd65f15878a43deefcc1d92f Mon Sep 17 00:00:00 2001 From: "Kalana B. Thilakarathna" Date: Mon, 19 Oct 2026 10:19:40 +0530 Subject: [PATCH] auth fix --- distribution_fe/contexts/auth-context.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/distribution_fe/contexts/auth-context.tsx b/distribution_fe/contexts/auth-context.tsx index 6a8ff82..8e09917 100644 --- a/distribution_fe/contexts/auth-context.tsx +++ b/distribution_fe/contexts/auth-context.tsx @@ -80,8 +80,9 @@ export function AuthProvider({ children }: { children: ReactNode }) { }, [router]) async function login(identifier: string, password: string) { - const { data: loginData } = await api.post<{ profile: User }>('/auth/login', { identifier, password, deviceName: 'Web' }) - setUser(loginData.profile) + const { data: res } = await api.post<{ statusCode: number; success: boolean; message: string; data: { profile: User } | null }>('/auth/login', { identifier, password, deviceName: 'Web' }) + if (!res.data) throw new Error(res.message ?? 'Invalid credentials') + setUser(res.data.profile) try { const { data: permData } = await api.get<{ permissions: string[] }>('/authorization/my-permissions') savePermissions(permData.permissions) -- 2.52.0