mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-22 09:07:45 +00:00
fix time check
This commit is contained in:
@@ -203,29 +203,43 @@ export async function checkMFAFactors(
|
|||||||
serviceUrl,
|
serviceUrl,
|
||||||
userId: session.factors?.user?.id,
|
userId: session.factors?.user?.id,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (
|
if (
|
||||||
user.user?.type?.case === "human" &&
|
user.user?.type?.case === "human" &&
|
||||||
user.user?.type?.value.mfaInitSkipped
|
user.user?.type?.value.mfaInitSkipped
|
||||||
) {
|
) {
|
||||||
}
|
const mfaInitSkippedTimestamp = timestampDate(
|
||||||
const params = new URLSearchParams({
|
user.user.type.value.mfaInitSkipped,
|
||||||
loginName: session.factors?.user?.loginName as string,
|
|
||||||
force: "false", // this defines if the mfa is not forced in the settings and can be skipped
|
|
||||||
checkAfter: "true", // this defines if the check is directly made after the setup
|
|
||||||
});
|
|
||||||
|
|
||||||
if (requestId) {
|
|
||||||
params.append("requestId", requestId);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (organization || session.factors?.user?.organizationId) {
|
|
||||||
params.append(
|
|
||||||
"organization",
|
|
||||||
organization ?? (session.factors?.user?.organizationId as string),
|
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: provide a way to setup passkeys on mfa page?
|
const mfaInitSkipLifetimeMillis =
|
||||||
return { redirect: `/mfa/set?` + params };
|
Number(loginSettings.mfaInitSkipLifetime.seconds) * 1000 +
|
||||||
|
loginSettings.mfaInitSkipLifetime.nanos / 1000000;
|
||||||
|
const currentTime = Date.now();
|
||||||
|
const mfaInitSkippedTime = mfaInitSkippedTimestamp.getTime();
|
||||||
|
const timeDifference = currentTime - mfaInitSkippedTime;
|
||||||
|
|
||||||
|
if (timeDifference > mfaInitSkipLifetimeMillis) {
|
||||||
|
const params = new URLSearchParams({
|
||||||
|
loginName: session.factors?.user?.loginName as string,
|
||||||
|
force: "false", // this defines if the mfa is not forced in the settings and can be skipped
|
||||||
|
checkAfter: "true", // this defines if the check is directly made after the setup
|
||||||
|
});
|
||||||
|
|
||||||
|
if (requestId) {
|
||||||
|
params.append("requestId", requestId);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (organization || session.factors?.user?.organizationId) {
|
||||||
|
params.append(
|
||||||
|
"organization",
|
||||||
|
organization ?? (session.factors?.user?.organizationId as string),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: provide a way to setup passkeys on mfa page?
|
||||||
|
return { redirect: `/mfa/set?` + params };
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user