Merge pull request 'fix: update login function to handle profile data correctly' (#68) from dev into production

Reviewed-on: #68
This commit was merged in pull request #68.
This commit is contained in:
2026-10-19 10:25:57 +05:30
+3 -3
View File
@@ -80,9 +80,9 @@ export function AuthProvider({ children }: { children: ReactNode }) {
}, [router]) }, [router])
async function login(identifier: string, password: string) { 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' }) 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.data) throw new Error(res.message ?? 'Invalid credentials') if (!res.profile) throw new Error(res.message ?? 'Invalid credentials')
setUser(res.data.profile) setUser(res.profile)
try { try {
const { data: permData } = await api.get<{ permissions: string[] }>('/authorization/my-permissions') const { data: permData } = await api.get<{ permissions: string[] }>('/authorization/my-permissions')
savePermissions(permData.permissions) savePermissions(permData.permissions)