fix oauth google sign
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
import type { Metadata } from "next";
|
||||
import { redirect } from "next/navigation";
|
||||
import { getServerSession } from "next-auth";
|
||||
import { authOptions } from "@/lib/auth";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Masuk",
|
||||
@@ -8,6 +11,15 @@ export const metadata: Metadata = {
|
||||
robots: { index: false, follow: true },
|
||||
};
|
||||
|
||||
export default function LoginLayout({ children }: { children: React.ReactNode }) {
|
||||
export default async function LoginLayout({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
// User yang sudah login tidak boleh mengakses halaman login lagi.
|
||||
const session = await getServerSession(authOptions);
|
||||
if (session?.user) {
|
||||
redirect(session.user.isAdmin ? "/admin" : "/");
|
||||
}
|
||||
return children;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user