mirror of
https://github.com/plankanban/planka.git
synced 2025-07-18 12:49:43 +02:00
43 lines
786 B
JavaScript
Executable file
43 lines
786 B
JavaScript
Executable file
const Errors = {
|
|
NOT_ENOUGH_RIGHTS: {
|
|
notEnoughRights: 'Not enough rights',
|
|
},
|
|
};
|
|
|
|
module.exports = {
|
|
inputs: {
|
|
name: {
|
|
type: 'string',
|
|
required: true,
|
|
},
|
|
},
|
|
|
|
exits: {
|
|
notEnoughRights: {
|
|
responseType: 'forbidden',
|
|
},
|
|
},
|
|
|
|
async fn(inputs) {
|
|
const { currentUser } = this.req;
|
|
|
|
if (!currentUser.isAdmin && !sails.config.custom.allowAllToCreateProjects) {
|
|
throw Errors.NOT_ENOUGH_RIGHTS;
|
|
}
|
|
|
|
const values = _.pick(inputs, ['name']);
|
|
|
|
const { project, projectManager } = await sails.helpers.projects.createOne.with({
|
|
values,
|
|
actorUser: currentUser,
|
|
request: this.req,
|
|
});
|
|
|
|
return {
|
|
item: project,
|
|
included: {
|
|
projectManagers: [projectManager],
|
|
},
|
|
};
|
|
},
|
|
};
|