mirror of
https://github.com/tinyauthapp/tinyauth.git
synced 2026-08-28 16:53:34 +08:00
fix: rabbit comments
This commit is contained in:
@@ -102,6 +102,7 @@ export const AuthorizePage = () => {
|
||||
return "";
|
||||
})();
|
||||
const [autoAuthorize, setAutoAuthorize] = useState(false);
|
||||
const [skipConsentChecked, setSkipConsentChecked] = useState(false);
|
||||
|
||||
const { mutate: authorizeMutate, isPending: authorizePending } = useMutation({
|
||||
mutationFn: () => {
|
||||
@@ -124,21 +125,34 @@ export const AuthorizePage = () => {
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
let active = true;
|
||||
const controller = new AbortController();
|
||||
|
||||
const checkSkipConsent = async () => {
|
||||
try {
|
||||
const res = await fetch(
|
||||
`/api/oidc/skip-consent?oidc_ticket=${encodeURIComponent(screenParams.oidc_ticket ?? "")}`,
|
||||
`/api/oidc/skip-consent?oidc_ticket=${encodeURIComponent( screenParams.oidc_ticket ?? "")}`,
|
||||
{ signal: controller.signal },
|
||||
);
|
||||
if (!res.ok) return;
|
||||
const parsed = skipConsentResponseSchema.safeParse(await res.json());
|
||||
if (!parsed.success || !parsed.data.skipConsent) return;
|
||||
if (!active || !parsed.success || !parsed.data.skipConsent) return;
|
||||
setAutoAuthorize(true);
|
||||
authorizeMutate();
|
||||
} catch {}
|
||||
} catch {
|
||||
// Fall back to manual consent on any failure (including abort).
|
||||
} finally {
|
||||
if (active) setSkipConsentChecked(true);
|
||||
}
|
||||
};
|
||||
|
||||
checkSkipConsent();
|
||||
}, []);
|
||||
|
||||
return () => {
|
||||
active = false;
|
||||
controller.abort();
|
||||
};
|
||||
}, [authorizeMutate, screenParams.oidc_ticket]);
|
||||
|
||||
if (!isOidc || !screenParams.oidc_ticket || !screenParams.oidc_scope) {
|
||||
return (
|
||||
@@ -199,7 +213,7 @@ export const AuthorizePage = () => {
|
||||
<CardFooter className="flex flex-col items-stretch gap-3">
|
||||
<Button
|
||||
onClick={() => authorizeMutate()}
|
||||
loading={authorizePending || autoAuthorize}
|
||||
loading={authorizePending || autoAuthorize || !skipConsentChecked}
|
||||
>
|
||||
{t("authorizeTitle")}
|
||||
</Button>
|
||||
|
||||
@@ -9,7 +9,7 @@ export default defineConfig({
|
||||
plugins: [react(), tailwindcss(), visualizer()],
|
||||
resolve: {
|
||||
alias: {
|
||||
"@": path.resolve(__dirname, "./src"),
|
||||
"@": path.resolve(import.meta.dirname, "./src"),
|
||||
},
|
||||
},
|
||||
build: {
|
||||
|
||||
@@ -266,6 +266,9 @@ func (controller *OIDCController) authorize(c *gin.Context) {
|
||||
}
|
||||
|
||||
func (controller *OIDCController) skipConsent(c *gin.Context) {
|
||||
c.Header("cache-control", "no-store")
|
||||
c.Header("pragma", "no-cache")
|
||||
|
||||
if controller.oidc == nil {
|
||||
c.JSON(500, SimpleResponse{
|
||||
Status: 500,
|
||||
|
||||
Reference in New Issue
Block a user