From ef75b5e6100219ab48cecc8cc53b611d93db935b Mon Sep 17 00:00:00 2001 From: alma Date: Mon, 21 Apr 2025 11:07:49 +0200 Subject: [PATCH] Page logicgit add .! --- app/signin/page.tsx | 123 +++----------------------------------------- 1 file changed, 6 insertions(+), 117 deletions(-) diff --git a/app/signin/page.tsx b/app/signin/page.tsx index 58060f5b..96030519 100644 --- a/app/signin/page.tsx +++ b/app/signin/page.tsx @@ -1,127 +1,16 @@ "use client"; +import { useEffect } from "react"; import { signIn } from "next-auth/react"; import { useRouter } from "next/navigation"; -import { useState } from "react"; export default function SignIn() { const router = useRouter(); - const [isLoading, setIsLoading] = useState(false); - const [error, setError] = useState(null); - const handleSubmit = async (e: React.FormEvent) => { - e.preventDefault(); - setIsLoading(true); - setError(null); + useEffect(() => { + // Redirect to the NextAuth.js sign-in page + router.push("/api/auth/signin"); + }, [router]); - try { - const formData = new FormData(e.currentTarget); - const email = formData.get("email"); - const password = formData.get("password"); - - const result = await signIn("credentials", { - email, - password, - redirect: false, - }); - - if (result?.error) { - setError("Invalid credentials"); - return; - } - - // Initialize folders after successful login - try { - const response = await fetch('/api/nextcloud/status'); - if (!response.ok) { - throw new Error('Failed to fetch Nextcloud folders'); - } - const data = await response.json(); - const folders = data.folders || []; - - // Cache the folders in localStorage for immediate access in Pages - localStorage.setItem('nextcloud_folders', JSON.stringify({ - folders, - timestamp: Date.now() - })); - } catch (error) { - console.error('Error initializing folders:', error); - // Continue with navigation even if folder initialization fails - } - - router.push("/"); - } catch (error) { - setError("An error occurred during sign in"); - console.error("Sign in error:", error); - } finally { - setIsLoading(false); - } - }; - - return ( -
-
-
-

- Sign in to your account -

-
- -
-
-
- - -
-
- - -
-
- - {error && ( -
{error}
- )} - -
- -
-
-
-
- ); + return null; }