mirror of
https://github.com/steveiliop56/tinyauth.git
synced 2026-04-08 14:57:58 +00:00
fix: review comments
This commit is contained in:
@@ -1,15 +1,14 @@
|
|||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
export const oidcParamsSchema = z.object({
|
export const oidcParamsSchema = z.object({
|
||||||
scope: z.string(),
|
scope: z.string().nonempty(),
|
||||||
response_type: z.string(),
|
response_type: z.string().nonempty(),
|
||||||
client_id: z.string(),
|
client_id: z.string().nonempty(),
|
||||||
redirect_uri: z.string(),
|
redirect_uri: z.string().nonempty(),
|
||||||
state: z.string().optional(),
|
state: z.string().optional(),
|
||||||
nonce: z.string().optional(),
|
nonce: z.string().optional(),
|
||||||
code_challenge: z.string().optional(),
|
code_challenge: z.string().optional(),
|
||||||
code_challenge_method: z.string().optional(),
|
code_challenge_method: z.string().optional(),
|
||||||
prompt: z.string().optional(),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export const useOIDCParams = (
|
export const useOIDCParams = (
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ export const AuthorizePage = () => {
|
|||||||
queryKey: ["client", oidcParams.values.client_id],
|
queryKey: ["client", oidcParams.values.client_id],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const res = await fetch(
|
const res = await fetch(
|
||||||
`/api/oidc/clients/${oidcParams.values.client_id}`,
|
`/api/oidc/clients/${encodeURIComponent(oidcParams.values.client_id)}`,
|
||||||
);
|
);
|
||||||
const data = await getOidcClientInfoSchema.parseAsync(await res.json());
|
const data = await getOidcClientInfoSchema.parseAsync(await res.json());
|
||||||
return data;
|
return data;
|
||||||
|
|||||||
@@ -106,6 +106,10 @@ export const LoginPage = () => {
|
|||||||
mutationKey: ["login"],
|
mutationKey: ["login"],
|
||||||
onSuccess: (data) => {
|
onSuccess: (data) => {
|
||||||
if (data.data.totpPending) {
|
if (data.data.totpPending) {
|
||||||
|
if (oidcParams.isOidc) {
|
||||||
|
window.location.replace(`/totp?${oidcParams.compiled}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
window.location.replace(
|
window.location.replace(
|
||||||
`/totp${redirectUri ? `?redirect_uri=${encodeURIComponent(redirectUri)}` : ""}`,
|
`/totp${redirectUri ? `?redirect_uri=${encodeURIComponent(redirectUri)}` : ""}`,
|
||||||
);
|
);
|
||||||
@@ -171,7 +175,7 @@ export const LoginPage = () => {
|
|||||||
return <Navigate to={`/authorize?${oidcParams.compiled}`} replace />;
|
return <Navigate to={`/authorize?${oidcParams.compiled}`} replace />;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isLoggedIn && redirectUri !== "") {
|
if (isLoggedIn && redirectUri !== undefined) {
|
||||||
return (
|
return (
|
||||||
<Navigate
|
<Navigate
|
||||||
to={`/continue${redirectUri ? `?redirect_uri=${encodeURIComponent(redirectUri)}` : ""}`}
|
to={`/continue${redirectUri ? `?redirect_uri=${encodeURIComponent(redirectUri)}` : ""}`}
|
||||||
|
|||||||
Reference in New Issue
Block a user