mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-03 22:26:07 +00:00
Throw an error when org authEnforced is enabled and user is trying to select org
This commit is contained in:
@@ -451,6 +451,13 @@ export const authLoginServiceFactory = ({
|
|||||||
const hasOrganizationMembership = userOrgs.some((org) => org.id === organizationId && org.userStatus !== "invited");
|
const hasOrganizationMembership = userOrgs.some((org) => org.id === organizationId && org.userStatus !== "invited");
|
||||||
const selectedOrg = await orgDAL.findById(organizationId);
|
const selectedOrg = await orgDAL.findById(organizationId);
|
||||||
|
|
||||||
|
// Check if authEnforced is true, if that's the case, throw an error
|
||||||
|
if (selectedOrg.authEnforced) {
|
||||||
|
throw new BadRequestError({
|
||||||
|
message: "Authentication is required by your organization before you can log in."
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (!hasOrganizationMembership) {
|
if (!hasOrganizationMembership) {
|
||||||
throw new ForbiddenRequestError({
|
throw new ForbiddenRequestError({
|
||||||
message: `User does not have access to the organization named ${selectedOrg?.name}`
|
message: `User does not have access to the organization named ${selectedOrg?.name}`
|
||||||
|
|||||||
Reference in New Issue
Block a user