Page logicgit add .
This commit is contained in:
parent
440a637c18
commit
219c46ef9b
@ -1,7 +1,13 @@
|
|||||||
|
import { Metadata } from "next";
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: "Enkun - Connexion",
|
||||||
|
};
|
||||||
|
|
||||||
export default function SignInLayout({
|
export default function SignInLayout({
|
||||||
children,
|
children,
|
||||||
}: {
|
}: {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
}) {
|
}) {
|
||||||
return <>{children}</>;
|
return children;
|
||||||
}
|
}
|
||||||
@ -1,35 +1,14 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { Metadata } from "next";
|
|
||||||
import { getServerSession } from "next-auth/next";
|
|
||||||
import { authOptions } from "@/app/api/auth/[...nextauth]/route";
|
|
||||||
import { redirect } from "next/navigation";
|
|
||||||
import { SignInForm } from "@/components/auth/signin-form";
|
|
||||||
import { signIn } from "next-auth/react";
|
import { signIn } from "next-auth/react";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { initializeNextcloudStructure } from "@/lib/nextcloud-init";
|
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export default function SignIn() {
|
||||||
title: "Enkun - Connexion",
|
|
||||||
};
|
|
||||||
|
|
||||||
export default async function SignIn({
|
|
||||||
searchParams,
|
|
||||||
}: {
|
|
||||||
searchParams: { callbackUrl?: string };
|
|
||||||
}) {
|
|
||||||
const session = await getServerSession(authOptions);
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const [error, setError] = useState<string | null>(null);
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
|
||||||
// If user is already authenticated and there's no specific callback URL,
|
|
||||||
// redirect to the home page
|
|
||||||
if (session && !searchParams.callbackUrl) {
|
|
||||||
redirect("/");
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
|
const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user