mirror of
https://github.com/plankanban/planka.git
synced 2025-07-22 22:59:44 +02:00
Project managers, board members, auto-update after reconnection, refactoring
This commit is contained in:
parent
d6cb1f6683
commit
b39119ace4
478 changed files with 21226 additions and 19495 deletions
51
server/api/controllers/project-managers/delete.js
Executable file
51
server/api/controllers/project-managers/delete.js
Executable file
|
@ -0,0 +1,51 @@
|
|||
const Errors = {
|
||||
PROJECT_MANAGER_NOT_FOUND: {
|
||||
projectManagerNotFound: 'Project manager not found',
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
inputs: {
|
||||
id: {
|
||||
type: 'string',
|
||||
regex: /^[0-9]+$/,
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
|
||||
exits: {
|
||||
projectManagerNotFound: {
|
||||
responseType: 'notFound',
|
||||
},
|
||||
},
|
||||
|
||||
async fn(inputs) {
|
||||
const { currentUser } = this.req;
|
||||
|
||||
let projectManager = await ProjectManager.findOne(inputs.id);
|
||||
|
||||
if (!projectManager) {
|
||||
throw Errors.PROJECT_MANAGER_NOT_FOUND;
|
||||
}
|
||||
|
||||
const isProjectManager = await sails.helpers.users.isProjectManager(
|
||||
currentUser.id,
|
||||
projectManager.projectId,
|
||||
);
|
||||
|
||||
if (!isProjectManager) {
|
||||
throw Errors.PROJECT_MANAGER_NOT_FOUND; // Forbidden
|
||||
}
|
||||
|
||||
// TODO: check if the last one
|
||||
projectManager = await sails.helpers.projectManagers.deleteOne(projectManager, this.req);
|
||||
|
||||
if (!projectManager) {
|
||||
throw Errors.PROJECT_MANAGER_NOT_FOUND;
|
||||
}
|
||||
|
||||
return {
|
||||
item: projectManager,
|
||||
};
|
||||
},
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue