fix(auth): display detailed validation error messages from backend
- Extract validation error details from backend response - Show specific error messages instead of generic 'Validation Error' - Join multiple validation errors with commas for better UX - Improves password validation error display for users
This commit is contained in:
@@ -56,6 +56,11 @@ export const AuthProvider = ({ children }) => {
|
|||||||
localStorage.setItem('user', JSON.stringify(userData));
|
localStorage.setItem('user', JSON.stringify(userData));
|
||||||
return userData;
|
return userData;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
// Handle validation errors with details
|
||||||
|
if (error.data?.details && Array.isArray(error.data.details)) {
|
||||||
|
const errorMessages = error.data.details.map(detail => detail.msg).join(', ');
|
||||||
|
throw new Error(errorMessages);
|
||||||
|
}
|
||||||
throw new Error(error.data?.error || 'Registration failed');
|
throw new Error(error.data?.error || 'Registration failed');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user