clean settings fetch

This commit is contained in:
Max Peintner
2024-12-12 17:52:41 +01:00
parent 911edd39b0
commit 8dc0e14f13
3 changed files with 7 additions and 7 deletions

View File

@@ -587,13 +587,11 @@ export async function setPassword(
type CheckSessionAndSetPasswordCommand = {
sessionId: string;
password: string;
forceMfa: boolean;
};
export async function checkSessionAndSetPassword({
sessionId,
password,
forceMfa,
}: CheckSessionAndSetPasswordCommand) {
const sessionCookie = await getSessionCookieById({ sessionId });
@@ -633,6 +631,13 @@ export async function checkSessionAndSetPassword({
(method) => !authmethods.authMethodTypes.includes(method),
);
const loginSettings = await getLoginSettings(
session.factors.user.organizationId,
);
const forceMfa = !!(
loginSettings?.forceMfa || loginSettings?.forceMfaLocalOnly
);
// if the user has no MFA but MFA is enforced, we can set a password otherwise we use the token of the user
if (forceMfa && hasNoMFAMethods) {
return userService.setPassword(payload, {}).catch((error) => {