fix(auth): enhance user login response handling and update User schema

- Log the response data on successful login for debugging purposes
- Improve error handling in user service by using safeParse for login response validation
- Update User schema to allow null values for optional fields, enhancing flexibility in user data handling
This commit is contained in:
AmirReza Jamali
2026-02-10 16:49:19 +03:30
parent cb6a48a6e6
commit 7755384d51
3 changed files with 21 additions and 16 deletions
+5 -1
View File
@@ -19,7 +19,11 @@ export const userService = {
try {
const response = await api.post(API_ENDPOINTS.USER.LOGIN, credentials);
return LoginResponseSchema.parse(response.data);
const result = LoginResponseSchema.safeParse(response.data);
if (!result.success) {
throw new Error(result.error.message);
}
return result.data;
} catch (error) {
console.error("ERROR caught in User Service Login:", error);
throw error;