mirror of
https://github.com/steveiliop56/tinyauth.git
synced 2026-02-23 01:11:59 +00:00
Compare commits
2 Commits
e8c0d9a54b
...
refactor/s
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ff771c5c22 | ||
|
|
d7b00ffeea |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -39,3 +39,6 @@ __debug_*
|
|||||||
|
|
||||||
# infisical
|
# infisical
|
||||||
/.infisical.json
|
/.infisical.json
|
||||||
|
|
||||||
|
# traefik data
|
||||||
|
/traefik
|
||||||
|
|||||||
@@ -32,34 +32,43 @@ export const ContinuePage = () => {
|
|||||||
cookieDomain,
|
cookieDomain,
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleRedirect = useCallback(() => {
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
hasRedirected.current = true;
|
hasRedirected.current = true;
|
||||||
|
window.location.assign(urlHref);
|
||||||
|
}, [urlHref]);
|
||||||
|
|
||||||
|
const handleRedirect = useCallback(() => {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
window.location.assign(url!);
|
redirectToTarget();
|
||||||
}, [url]);
|
}, [redirectToTarget]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isLoggedIn) {
|
if (!shouldAutoRedirect) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hasRedirected.current) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
|
||||||
(!valid || !allowedProto || !trusted || httpsDowngrade) &&
|
|
||||||
!disableUiWarnings
|
|
||||||
) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto = setTimeout(() => {
|
const auto = setTimeout(() => {
|
||||||
handleRedirect();
|
redirectToTarget();
|
||||||
}, 100);
|
}, 100);
|
||||||
|
|
||||||
const reveal = setTimeout(() => {
|
const reveal = setTimeout(() => {
|
||||||
setIsLoading(false);
|
|
||||||
setShowRedirectButton(true);
|
setShowRedirectButton(true);
|
||||||
}, 5000);
|
}, 5000);
|
||||||
|
|
||||||
@@ -67,18 +76,7 @@ export const ContinuePage = () => {
|
|||||||
clearTimeout(auto);
|
clearTimeout(auto);
|
||||||
clearTimeout(reveal);
|
clearTimeout(reveal);
|
||||||
};
|
};
|
||||||
}, [
|
}, [shouldAutoRedirect, redirectToTarget]);
|
||||||
isLoggedIn,
|
|
||||||
hasRedirected,
|
|
||||||
valid,
|
|
||||||
allowedProto,
|
|
||||||
trusted,
|
|
||||||
httpsDowngrade,
|
|
||||||
disableUiWarnings,
|
|
||||||
setIsLoading,
|
|
||||||
handleRedirect,
|
|
||||||
setShowRedirectButton,
|
|
||||||
]);
|
|
||||||
|
|
||||||
if (!isLoggedIn) {
|
if (!isLoggedIn) {
|
||||||
return (
|
return (
|
||||||
@@ -89,11 +87,11 @@ export const ContinuePage = () => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!valid || !allowedProto) {
|
if (!hasValidRedirect) {
|
||||||
return <Navigate to="/logout" replace />;
|
return <Navigate to="/logout" replace />;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!trusted && !disableUiWarnings) {
|
if (showUntrustedWarning) {
|
||||||
return (
|
return (
|
||||||
<Card role="alert" aria-live="assertive" className="min-w-xs sm:min-w-sm">
|
<Card role="alert" aria-live="assertive" className="min-w-xs sm:min-w-sm">
|
||||||
<CardHeader>
|
<CardHeader>
|
||||||
@@ -113,7 +111,7 @@ export const ContinuePage = () => {
|
|||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardFooter className="flex flex-col items-stretch gap-2">
|
<CardFooter className="flex flex-col items-stretch gap-2">
|
||||||
<Button
|
<Button
|
||||||
onClick={() => handleRedirect()}
|
onClick={handleRedirect}
|
||||||
loading={isLoading}
|
loading={isLoading}
|
||||||
variant="destructive"
|
variant="destructive"
|
||||||
>
|
>
|
||||||
@@ -131,7 +129,7 @@ export const ContinuePage = () => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (httpsDowngrade && !disableUiWarnings) {
|
if (showInsecureWarning) {
|
||||||
return (
|
return (
|
||||||
<Card role="alert" aria-live="assertive" className="min-w-xs sm:min-w-sm">
|
<Card role="alert" aria-live="assertive" className="min-w-xs sm:min-w-sm">
|
||||||
<CardHeader>
|
<CardHeader>
|
||||||
@@ -150,7 +148,7 @@ export const ContinuePage = () => {
|
|||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardFooter className="flex flex-col items-stretch gap-2">
|
<CardFooter className="flex flex-col items-stretch gap-2">
|
||||||
<Button
|
<Button
|
||||||
onClick={() => handleRedirect()}
|
onClick={handleRedirect}
|
||||||
loading={isLoading}
|
loading={isLoading}
|
||||||
variant="warning"
|
variant="warning"
|
||||||
>
|
>
|
||||||
@@ -178,7 +176,7 @@ export const ContinuePage = () => {
|
|||||||
</CardHeader>
|
</CardHeader>
|
||||||
{showRedirectButton && (
|
{showRedirectButton && (
|
||||||
<CardFooter className="flex flex-col items-stretch">
|
<CardFooter className="flex flex-col items-stretch">
|
||||||
<Button onClick={() => handleRedirect()}>
|
<Button onClick={handleRedirect}>
|
||||||
{t("continueRedirectManually")}
|
{t("continueRedirectManually")}
|
||||||
</Button>
|
</Button>
|
||||||
</CardFooter>
|
</CardFooter>
|
||||||
|
|||||||
Reference in New Issue
Block a user