Skip to content
Merged
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@ __debug_*

# infisical
/.infisical.json

# traefik data
/traefik
68 changes: 33 additions & 35 deletions frontend/src/pages/continue-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,53 +32,51 @@ export const ContinuePage = () => {
cookieDomain,
);

const handleRedirect = useCallback(() => {
hasRedirected.current = true;
setIsLoading(true);
window.location.assign(url!);
}, [url]);

useEffect(() => {
if (!isLoggedIn) {
const urlHref = url?.href;

const hasValidRedirect = valid && allowedProto;
const showUntrustedWarning =
hasValidRedirect && !trusted && !disableUiWarnings;
const showInsecureWarning =
hasValidRedirect && httpsDowngrade && !disableUiWarnings;
const shouldAutoRedirect =
isLoggedIn &&
hasValidRedirect &&
!showUntrustedWarning &&
!showInsecureWarning;

const redirectToTarget = useCallback(() => {
if (!urlHref || hasRedirected.current) {
return;
}

if (hasRedirected.current) {
return;
}
hasRedirected.current = true;
window.location.assign(urlHref);
}, [urlHref]);

const handleRedirect = useCallback(() => {
setIsLoading(true);
redirectToTarget();
}, [redirectToTarget]);
Comment on lines +57 to +60
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

isLoading is never reset if redirectToTarget is a no-op.

If handleRedirect is called but redirectToTarget bails out (e.g., hasRedirected.current is already true), isLoading stays true and the button remains in its loading state permanently. Given the rendering guards this is very unlikely to surface, but worth noting.

🤖 Prompt for AI Agents
In `@frontend/src/pages/continue-page.tsx` around lines 57 - 60, handleRedirect
sets isLoading true unconditionally but never resets it if redirectToTarget is a
no-op; change the logic so we only set loading when a redirect will occur or we
always clear loading when redirectToTarget bails. Specifically, either (a) make
redirectToTarget return a boolean/promise indicating whether a redirect happened
and in handleRedirect call setIsLoading(true) only if it will redirect (or
setIsLoading(false) when it returns false), or (b) check hasRedirected.current
before setting loading in handleRedirect, or wrap the call in try/finally and
call setIsLoading(false) when no navigation occurred; reference handleRedirect,
redirectToTarget, hasRedirected.current, and setIsLoading when making the
change.


if (
(!valid || !allowedProto || !trusted || httpsDowngrade) &&
!disableUiWarnings
) {
useEffect(() => {
if (!shouldAutoRedirect) {
return;
}

const auto = setTimeout(() => {
handleRedirect();
redirectToTarget();
}, 100);

const reveal = setTimeout(() => {
setIsLoading(false);
setShowRedirectButton(true);
}, 5000);

return () => {
clearTimeout(auto);
clearTimeout(reveal);
};
}, [
isLoggedIn,
hasRedirected,
valid,
allowedProto,
trusted,
httpsDowngrade,
disableUiWarnings,
setIsLoading,
handleRedirect,
setShowRedirectButton,
]);
}, [shouldAutoRedirect, redirectToTarget]);

if (!isLoggedIn) {
return (
Expand All @@ -89,11 +87,11 @@ export const ContinuePage = () => {
);
}

if (!valid || !allowedProto) {
if (!hasValidRedirect) {
return <Navigate to="/logout" replace />;
}

if (!trusted && !disableUiWarnings) {
if (showUntrustedWarning) {
return (
<Card role="alert" aria-live="assertive" className="min-w-xs sm:min-w-sm">
<CardHeader>
Expand All @@ -113,7 +111,7 @@ export const ContinuePage = () => {
</CardHeader>
<CardFooter className="flex flex-col items-stretch gap-2">
<Button
onClick={() => handleRedirect()}
onClick={handleRedirect}
loading={isLoading}
variant="destructive"
>
Expand All @@ -131,7 +129,7 @@ export const ContinuePage = () => {
);
}

if (httpsDowngrade && !disableUiWarnings) {
if (showInsecureWarning) {
return (
<Card role="alert" aria-live="assertive" className="min-w-xs sm:min-w-sm">
<CardHeader>
Expand All @@ -150,7 +148,7 @@ export const ContinuePage = () => {
</CardHeader>
<CardFooter className="flex flex-col items-stretch gap-2">
<Button
onClick={() => handleRedirect()}
onClick={handleRedirect}
loading={isLoading}
variant="warning"
>
Expand Down Expand Up @@ -178,7 +176,7 @@ export const ContinuePage = () => {
</CardHeader>
{showRedirectButton && (
<CardFooter className="flex flex-col items-stretch">
<Button onClick={() => handleRedirect()}>
<Button onClick={handleRedirect}>
{t("continueRedirectManually")}
</Button>
</CardFooter>
Expand Down