mirror of
https://github.com/Infisical/infisical.git
synced 2026-01-09 15:38:03 -05:00
feat: warn users when they're already part of an org and are trying to
accept an invite
This commit is contained in:
2
backend/package-lock.json
generated
2
backend/package-lock.json
generated
@@ -9962,7 +9962,6 @@
|
||||
"resolved": "https://registry.npmjs.org/zod/-/zod-4.1.13.tgz",
|
||||
"integrity": "sha512-AvvthqfqrAhNH9dnfmrfKzX5upOdjUVJYFqNSlkmGf64gRaTzlPwz99IHYnVs28qYAybvAlBV+H7pn0saFY4Ig==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/colinhacks"
|
||||
}
|
||||
@@ -19188,7 +19187,6 @@
|
||||
"resolved": "https://registry.npmjs.org/express/-/express-4.21.2.tgz",
|
||||
"integrity": "sha512-28HqgMZAmih1Czt9ny7qr6ek2qddF4FclbMzwhCREB6OFfH+rXAnuNCwo1/wFvrtbgsQDb4kSbX9de9lFbrXnA==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"accepts": "~1.3.8",
|
||||
"array-flatten": "1.1.1",
|
||||
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
ProjectPermissionGroupActions,
|
||||
ProjectPermissionIdentityActions,
|
||||
ProjectPermissionKmipActions,
|
||||
ProjectPermissionMcpEndpointActions,
|
||||
ProjectPermissionMemberActions,
|
||||
ProjectPermissionPamAccountActions,
|
||||
ProjectPermissionPamSessionActions,
|
||||
@@ -28,7 +29,6 @@ import {
|
||||
ProjectPermissionSecretScanningDataSourceActions,
|
||||
ProjectPermissionSecretScanningFindingActions,
|
||||
ProjectPermissionSecretSyncActions,
|
||||
ProjectPermissionMcpEndpointActions,
|
||||
ProjectPermissionSet,
|
||||
ProjectPermissionSshHostActions,
|
||||
ProjectPermissionSub
|
||||
|
||||
@@ -937,10 +937,25 @@ export const orgServiceFactory = ({
|
||||
[`${TableName.Membership}.scopeOrgId` as "scopeOrgId"]: orgId
|
||||
});
|
||||
|
||||
if (!orgMembership)
|
||||
if (!orgMembership) {
|
||||
// Check if user is already a member
|
||||
const [acceptedMembership] = await orgDAL.findMembership({
|
||||
[`${TableName.Membership}.actorUserId` as "actorUserId"]: user.id,
|
||||
scope: AccessScope.Organization,
|
||||
status: OrgMembershipStatus.Accepted,
|
||||
[`${TableName.Membership}.scopeOrgId` as "scopeOrgId"]: orgId
|
||||
});
|
||||
|
||||
if (acceptedMembership) {
|
||||
throw new BadRequestError({
|
||||
message: "User is already a member of this organization"
|
||||
});
|
||||
}
|
||||
|
||||
throw new NotFoundError({
|
||||
message: "No pending invitation found"
|
||||
});
|
||||
}
|
||||
|
||||
const organization = await orgDAL.findById(orgId);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user