Fix admin login and CORS issues
- Update CORS configuration to allow frontend on port 3005 - Fix auth service to map email field to username for backend compatibility - Add loading state handling in AdminLayout - Add error boundary to dashboard route - Fix unused parameter warning in login function 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -35,15 +35,21 @@ export const AdminAuthProvider: React.FC<AdminAuthProviderProps> = ({ children }
|
||||
|
||||
useEffect(() => {
|
||||
// Check if user has a valid token on mount
|
||||
const token = getAuthToken(true);
|
||||
if (token) {
|
||||
// TODO: Validate token with backend and get user info
|
||||
setIsAuthenticated(true);
|
||||
}
|
||||
setIsLoading(false);
|
||||
const checkAuth = async () => {
|
||||
const token = getAuthToken(true);
|
||||
if (token) {
|
||||
// For now, just assume the token is valid
|
||||
// TODO: Validate token with backend and get user info
|
||||
setIsAuthenticated(true);
|
||||
}
|
||||
setIsLoading(false);
|
||||
};
|
||||
|
||||
checkAuth();
|
||||
}, []);
|
||||
|
||||
const login = (_token: string, user: AdminUser) => {
|
||||
// Token is already stored in cookie by authService
|
||||
setUser(user);
|
||||
setIsAuthenticated(true);
|
||||
setError(null);
|
||||
|
||||
Reference in New Issue
Block a user