fix: update login function to handle profile data correctly
CI/CD - ERP Distribution / Build & Deploy Backend (pull_request) Failing after 12m43s
CI/CD - ERP Distribution / Build & Deploy Frontend (pull_request) Failing after 16m30s

This commit is contained in:
Kalana B. Thilakarathna
2026-10-19 10:25:29 +05:30
parent da29492798
commit f3f2b71bd4
+3 -3
View File
@@ -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)