diff --git a/app/signin/page.tsx b/app/signin/page.tsx index 4a8ac934..f5ff9c18 100644 --- a/app/signin/page.tsx +++ b/app/signin/page.tsx @@ -1,62 +1,13 @@ "use client"; import { signIn } from "next-auth/react"; -import { useRouter } from "next/navigation"; -import { useState } from "react"; +import { useEffect } 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); - - try { - const formData = new FormData(e.currentTarget); - const email = formData.get("email"); - const password = formData.get("password"); - - const result = await signIn("keycloak", { - 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); - } - }; + useEffect(() => { + // Trigger Keycloak sign-in + signIn("keycloak", { callbackUrl: "/" }); + }, []); return (

- Sign in to your account + Redirecting to login...

- -
-
-
- - -
-
- - -
-
- - {error && ( -
{error}
- )} - -
- -
-
);