buster/web/src/app/auth/login/page.tsx

36 lines
1015 B
TypeScript

import { LoginForm } from '@appComponents/LoginComponents/LoginForm';
import { useBusterSupabaseAuthMethods } from '@/hooks/useBusterSupabaseAuthMethods';
import { redirect } from 'next/navigation';
import { BusterRoutes, createBusterRoute } from '@/routes';
import { useSupabaseServerContext } from '@/context/Supabase/useSupabaseContext';
export default async function Login({}: {}) {
const supabase = await useSupabaseServerContext();
const { user } = supabase;
const {
signInWithEmailAndPassword,
signInWithGoogle,
signInWithGithub,
signInWithAzure,
signUp
} = useBusterSupabaseAuthMethods();
if (user?.id) {
return redirect(
createBusterRoute({
route: BusterRoutes.APP_ROOT
})
);
}
return (
<LoginForm
user={user}
signInWithEmailAndPassword={signInWithEmailAndPassword}
signInWithGoogle={signInWithGoogle}
signInWithGithub={signInWithGithub}
signInWithAzure={signInWithAzure}
signUp={signUp}
/>
);
}