feat(auth): Add authorize page
This commit is contained in:
17
app/page.tsx
17
app/page.tsx
@@ -1,13 +1,26 @@
|
||||
import { cookies } from "next/headers";
|
||||
import { redirect } from "next/navigation";
|
||||
|
||||
import { LoginContainer, LoginSuccessContainer } from "@/components/core/login-form";
|
||||
|
||||
// Get the url before redirect to this page
|
||||
export interface HomeParams {
|
||||
returnTo?: string;
|
||||
}
|
||||
|
||||
export default async function Home() {
|
||||
export default async function Home({
|
||||
searchParams
|
||||
}: {
|
||||
searchParams: Promise<HomeParams>
|
||||
}) {
|
||||
const params = await searchParams;
|
||||
const cookieStore = await cookies();
|
||||
const token = cookieStore.get("token");
|
||||
|
||||
// If token exists and we came from a redirect, go back
|
||||
if (token && params.returnTo) {
|
||||
redirect(params.returnTo);
|
||||
}
|
||||
|
||||
if (token) {
|
||||
return (
|
||||
<div className="flex justify-center items-center h-screen">
|
||||
|
||||
Reference in New Issue
Block a user