mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-21 23:17:39 +00:00
fix time check
This commit is contained in:
@@ -203,11 +203,23 @@ 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(
|
||||||
|
user.user.type.value.mfaInitSkipped,
|
||||||
|
);
|
||||||
|
|
||||||
|
const mfaInitSkipLifetimeMillis =
|
||||||
|
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({
|
const params = new URLSearchParams({
|
||||||
loginName: session.factors?.user?.loginName as string,
|
loginName: session.factors?.user?.loginName as string,
|
||||||
force: "false", // this defines if the mfa is not forced in the settings and can be skipped
|
force: "false", // this defines if the mfa is not forced in the settings and can be skipped
|
||||||
@@ -229,3 +241,5 @@ export async function checkMFAFactors(
|
|||||||
return { redirect: `/mfa/set?` + params };
|
return { redirect: `/mfa/set?` + params };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user