mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-13 02:29:26 +00:00
improvement: add bulk delete users support, bulk actions server admin table support, overflow/truncation and dropdown improvements
This commit is contained in:
@@ -704,10 +704,39 @@ export const superAdminServiceFactory = ({
|
||||
};
|
||||
|
||||
const deleteUser = async (userId: string) => {
|
||||
const superAdmins = await userDAL.find({
|
||||
superAdmin: true
|
||||
});
|
||||
|
||||
if (superAdmins.length === 1 && superAdmins[0].id === userId) {
|
||||
throw new BadRequestError({
|
||||
message: "Cannot delete the only server admin on this instance. Add another server admin to delete this user."
|
||||
});
|
||||
}
|
||||
|
||||
const user = await userDAL.deleteById(userId);
|
||||
return user;
|
||||
};
|
||||
|
||||
const deleteUsers = async (userIds: string[]) => {
|
||||
const superAdmins = await userDAL.find({
|
||||
superAdmin: true
|
||||
});
|
||||
|
||||
if (superAdmins.every((superAdmin) => userIds.includes(superAdmin.id))) {
|
||||
throw new BadRequestError({
|
||||
message: "Instance must have at least one server admin. Add another server admin to delete these users."
|
||||
});
|
||||
}
|
||||
|
||||
const users = await userDAL.delete({
|
||||
$in: {
|
||||
id: userIds
|
||||
}
|
||||
});
|
||||
return users;
|
||||
};
|
||||
|
||||
const deleteIdentitySuperAdminAccess = async (identityId: string, actorId: string) => {
|
||||
const identity = await identityDAL.findById(identityId);
|
||||
if (!identity) {
|
||||
@@ -730,6 +759,17 @@ export const superAdminServiceFactory = ({
|
||||
throw new NotFoundError({ name: "User", message: "User not found" });
|
||||
}
|
||||
|
||||
const superAdmins = await userDAL.find({
|
||||
superAdmin: true
|
||||
});
|
||||
|
||||
if (superAdmins.length === 1 && superAdmins[0].id === userId) {
|
||||
throw new BadRequestError({
|
||||
message:
|
||||
"Cannot remove the only server admin on this instance. Add another server admin to remove status for this user."
|
||||
});
|
||||
}
|
||||
|
||||
const updatedUser = userDAL.updateById(userId, { superAdmin: false });
|
||||
|
||||
return updatedUser;
|
||||
@@ -913,6 +953,7 @@ export const superAdminServiceFactory = ({
|
||||
initializeAdminIntegrationConfigSync,
|
||||
initializeEnvConfigSync,
|
||||
getEnvOverrides,
|
||||
getEnvOverridesOrganized
|
||||
getEnvOverridesOrganized,
|
||||
deleteUsers
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user