Fix authEnforced returning a token when org has authEnforced enabled

This commit is contained in:
Carlos Monastyrski
2025-07-14 14:46:26 -03:00
parent e84bb94868
commit ee7bb2dd4d

View File

@@ -1274,6 +1274,8 @@ export const orgServiceFactory = ({
message: "No pending invitation found"
});
const organization = await orgDAL.findById(orgId);
await tokenService.validateTokenForUser({
type: TokenType.TOKEN_EMAIL_ORG_INVITATION,
userId: user.id,
@@ -1296,6 +1298,13 @@ export const orgServiceFactory = ({
return { user };
}
if (
organization.authEnforced &&
!(organization.bypassOrgAuthEnabled && orgMembership.role === OrgMembershipRole.Admin)
) {
return { user };
}
const appCfg = getConfig();
const token = jwt.sign(
{