diff --git a/app/loggedout/layout.tsx b/app/loggedout/layout.tsx
new file mode 100644
index 00000000..8de991d5
--- /dev/null
+++ b/app/loggedout/layout.tsx
@@ -0,0 +1,7 @@
+export default function LoggedOutLayout({
+ children,
+}: {
+ children: React.ReactNode;
+}) {
+ return children;
+}
\ No newline at end of file
diff --git a/app/loggedout/page.tsx b/app/loggedout/page.tsx
new file mode 100644
index 00000000..a042a7ec
--- /dev/null
+++ b/app/loggedout/page.tsx
@@ -0,0 +1,49 @@
+"use client";
+
+import { useEffect } from "react";
+import { clearAuthCookies } from "@/lib/session";
+import Link from "next/link";
+
+export default function LoggedOut() {
+ // Clear auth cookies again on this page as an extra precaution
+ useEffect(() => {
+ // Run an additional cookie cleanup on this page
+ clearAuthCookies();
+
+ // Also clear session storage
+ try {
+ sessionStorage.clear();
+ } catch (e) {
+ console.error('Error clearing session storage:', e);
+ }
+ }, []);
+
+ return (
+
+
+
+
+ You have been logged out
+
+
+ Your session has been successfully terminated and all authentication data has been cleared.
+
+
+ Sign In Again
+
+
+
+
+ );
+}
\ No newline at end of file
diff --git a/app/signin/page.tsx b/app/signin/page.tsx
index d0564a92..bf95672c 100644
--- a/app/signin/page.tsx
+++ b/app/signin/page.tsx
@@ -9,15 +9,34 @@ export default function SignIn() {
const searchParams = useSearchParams();
const signedOut = searchParams.get('signedOut') === 'true';
const [isRedirecting, setIsRedirecting] = useState(false);
+ const [isFromLogout, setIsFromLogout] = useState(false);
+
+ // Check if we came from the loggedout page
+ useEffect(() => {
+ const referrer = document.referrer;
+ const isFromLoggedOutPage = referrer &&
+ (referrer.includes('/loggedout') || referrer.includes('/signout'));
+
+ if (isFromLoggedOutPage) {
+ console.log('Detected navigation from logout page, preventing auto-login');
+ setIsFromLogout(true);
+ }
+ }, []);
useEffect(() => {
- // Only automatically sign in if not explicitly signed out
- if (!signedOut && !isRedirecting) {
+ // Only automatically sign in if not explicitly signed out and not coming from logout
+ if (!signedOut && !isFromLogout && !isRedirecting && !session) {
setIsRedirecting(true);
- // Trigger Keycloak sign-in
- signIn("keycloak", { callbackUrl: "/" });
+ console.log('Triggering automatic sign-in');
+ // Add a small delay to avoid immediate redirect which can cause loops
+ const timer = setTimeout(() => {
+ // Trigger Keycloak sign-in
+ signIn("keycloak", { callbackUrl: "/" });
+ }, 500);
+
+ return () => clearTimeout(timer);
}
- }, [signedOut, isRedirecting]);
+ }, [signedOut, isRedirecting, isFromLogout, session]);
useEffect(() => {
if (session?.user && !session.user.nextcloudInitialized) {
@@ -34,6 +53,8 @@ export default function SignIn() {
}
}, [session]);
+ const showManualLoginButton = signedOut || isFromLogout || isRedirecting;
+
return (
- {signedOut ? (
+ {showManualLoginButton ? (
<>
- You have been signed out
+ {signedOut || isFromLogout ? 'You have been signed out' : 'Welcome Back'}
- Click below to sign in again
+ Click below to sign in