Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/app/auth/resource/[resourceGuid]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,13 @@ export default async function ResourceAuthPage(props: {
} catch (e) {}
}

// postAuthPath is a resource-level default landing path. Only apply it
// when no ?redirect= deep-path was supplied by the original request.
// If searchParams.redirect has already set a specific URL we must honour
// it — overriding it here is what caused users to be sent to the wrong
// page after SSO login when their Pangolin session had expired.
const normalizedPostAuthPath = normalizePostAuthPath(authInfo.postAuthPath);
if (normalizedPostAuthPath) {
if (normalizedPostAuthPath && !searchParams.redirect) {
redirectUrl = new URL(authInfo.url).origin + normalizedPostAuthPath;
}

Expand Down
11 changes: 8 additions & 3 deletions src/components/ResourceAuthPortal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,6 @@ export default function ResourceAuthPortal(props: ResourceAuthPortalProps) {
let isAllowed = false;
try {
const response = await resourceAccessProxy(props.resource.id);
console.log("response", response);
if (response.error) {
setAccessDenied(true);
} else {
Expand All @@ -311,8 +310,14 @@ export default function ResourceAuthPortal(props: ResourceAuthPortalProps) {
}

if (isAllowed) {
// window.location.href = props.redirect;
router.refresh();
// Use a full page reload so the browser issues a fresh request to
// this URL (which still carries the ?redirect= query parameter).
// The server then performs the SSO token exchange and issues a
// server-side redirect() to the original deep-path URL.
// router.refresh() alone does NOT reliably follow server-side
// redirect() calls in the Next.js App Router, causing users to
// land on the Pangolin panel instead of the desired resource.
window.location.reload();
}
}

Expand Down
Loading