Dev #71
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user