You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by la...@apache.org on 2026/07/23 19:19:06 UTC
(airavata-custos) 34/35: Route unlinked users to the request-access page, not sign-out
This is an automated email from the ASF dual-hosted git repository.
lahirujayathilake pushed a commit to branch pearc26
in repository https://gitbox.apache.org/repos/asf/airavata-custos.git
commit c3830d4c1e5b639d15bdcfb37be4f922c6129fb1
Author: lahiruj <la...@gmail.com>
AuthorDate: Thu Jul 23 13:20:04 2026 -0400
Route unlinked users to the request-access page, not sign-out
---
web/src/shared/auth/useAuthErrorHandler.ts | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/web/src/shared/auth/useAuthErrorHandler.ts b/web/src/shared/auth/useAuthErrorHandler.ts
index 39931afcf..ebcade83a 100644
--- a/web/src/shared/auth/useAuthErrorHandler.ts
+++ b/web/src/shared/auth/useAuthErrorHandler.ts
@@ -18,6 +18,7 @@
"use client";
import { signOut } from "next-auth/react";
+import { useRouter } from "next/navigation";
import { useCallback } from "react";
import { ApiError } from "@/shared/api/client";
@@ -30,6 +31,7 @@ function readCode(body: unknown): string | null {
}
export function useAuthErrorHandler() {
+ const router = useRouter();
return useCallback(
(error: unknown) => {
if (!(error instanceof ApiError)) return;
@@ -41,13 +43,15 @@ export function useAuthErrorHandler() {
void signOut({ callbackUrl: "/sign-in?error=session_expired" });
return;
}
+ // A signed-in user whose identity is not linked keeps their session and
+ // goes to the request-access page, not signed out.
if (error.status === 401 && code === "identity_not_linked") {
- void signOut({ callbackUrl: "/sign-in?error=identity_not_linked" });
+ router.push("/no-access?reason=identity_not_linked");
return;
}
// 403 insufficient_privilege and other codes fall through to the
// query's local ErrorState — no global takeover.
},
- [],
+ [router],
);
}