fix: stabilize auth-to-tenant flow and correct tenant header mapping
Resolve post-login routing and tenant context issues by proxying frontend API calls, redirecting authenticated users away from /login, and hardening club loading with retries/loading guards. Align tenant identity end-to-end by returning tenantId in /api/clubs/me and sending X-Tenant-Id from cookie-backed tenantId instead of local clubId, restoring authorized tasks/shifts data access after club selection.
This commit is contained in:
@@ -1,12 +1,24 @@
|
||||
'use client';
|
||||
|
||||
import { signIn } from 'next-auth/react';
|
||||
import { useEffect } from 'react';
|
||||
import { signIn, useSession } from 'next-auth/react';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { Card, CardHeader, CardTitle, CardContent } from '@/components/ui/card';
|
||||
import { Button } from '@/components/ui/button';
|
||||
|
||||
export default function LoginPage() {
|
||||
const { status } = useSession();
|
||||
const router = useRouter();
|
||||
|
||||
// Redirect to dashboard if already authenticated
|
||||
useEffect(() => {
|
||||
if (status === 'authenticated') {
|
||||
router.push('/dashboard');
|
||||
}
|
||||
}, [status, router]);
|
||||
|
||||
const handleSignIn = () => {
|
||||
signIn('keycloak');
|
||||
signIn('keycloak', { callbackUrl: '/dashboard' });
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user