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