chore: remove redundant delete role mutation

This commit is contained in:
Ali BARIN
2024-09-05 15:31:59 +00:00
parent 66fe84e126
commit e5366534ed
4 changed files with 0 additions and 49 deletions

View File

@@ -2,7 +2,6 @@ import createConnection from './mutations/create-connection.js';
import createStep from './mutations/create-step.js';
import createUser from './mutations/create-user.ee.js';
import deleteFlow from './mutations/delete-flow.js';
import deleteRole from './mutations/delete-role.ee.js';
import duplicateFlow from './mutations/duplicate-flow.js';
import generateAuthUrl from './mutations/generate-auth-url.js';
import registerUser from './mutations/register-user.ee.js';
@@ -28,7 +27,6 @@ const mutationResolvers = {
createUser,
deleteCurrentUser,
deleteFlow,
deleteRole,
deleteStep,
duplicateFlow,
executeFlow,

View File

@@ -1,36 +0,0 @@
import Role from '../../models/role.js';
import SamlAuthProvider from '../../models/saml-auth-provider.ee.js';
const deleteRole = async (_parent, params, context) => {
context.currentUser.can('delete', 'Role');
const role = await Role.query().findById(params.input.id).throwIfNotFound();
const count = await role.$relatedQuery('users').resultSize();
if (count > 0) {
throw new Error('All users must be migrated away from the role!');
}
if (role.isAdmin) {
throw new Error('Admin role cannot be deleted!');
}
const samlAuthProviderUsingDefaultRole = await SamlAuthProvider.query()
.where({ default_role_id: role.id })
.limit(1)
.first();
if (samlAuthProviderUsingDefaultRole) {
throw new Error(
'You need to change the default role in the SAML configuration before deleting this role.'
);
}
// delete permissions first
await role.$relatedQuery('permissions').delete();
await role.$query().delete();
return true;
};
export default deleteRole;

View File

@@ -8,7 +8,6 @@ type Mutation {
createUser(input: CreateUserInput): UserWithAcceptInvitationUrl
deleteCurrentUser: Boolean
deleteFlow(input: DeleteFlowInput): Boolean
deleteRole(input: DeleteRoleInput): Boolean
deleteStep(input: DeleteStepInput): Step
duplicateFlow(input: DuplicateFlowInput): Flow
executeFlow(input: ExecuteFlowInput): executeFlowType
@@ -334,10 +333,6 @@ input UpdateCurrentUserInput {
fullName: String
}
input DeleteRoleInput {
id: String!
}
"""
The `JSONObject` scalar type represents JSON objects as specified by [ECMA-404](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf).
"""

View File

@@ -1,6 +0,0 @@
import { gql } from '@apollo/client';
export const DELETE_ROLE = gql`
mutation DeleteRole($input: DeleteRoleInput) {
deleteRole(input: $input)
}
`;