1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-08-01 19:45:26 +02:00
This commit is contained in:
Samuel 2025-07-18 09:22:15 +02:00 committed by GitHub
commit ffafa8c8f1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 295 additions and 1 deletions

View file

@ -0,0 +1,51 @@
/*!
* Copyright (c) 2025 PLANKA Software GmbH
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
*/
const { idInput } = require('../../../utils/inputs');
const Errors = {
USER_NOT_FOUND: {
userNotFound: 'User not found',
},
ALREADY_EXISTS: {
alreadyExists: 'API key already exists',
},
};
module.exports = {
inputs: {
id: {
...idInput,
required: true,
},
},
exits: {
userNotFound: {
responseType: 'notFound',
},
alreadyExists: {
responseType: 'conflict',
},
},
async fn(inputs) {
const { id } = inputs;
const { apiKey } = await sails.helpers.apiKey.createAndStore
.with({
id,
cycle: false,
})
.intercept('alreadyExists', () => Errors.ALREADY_EXISTS)
.intercept('userNotFound', () => Errors.USER_NOT_FOUND);
return {
item: {
apiKey,
},
};
},
};

View file

@ -0,0 +1,51 @@
/*!
* Copyright (c) 2025 PLANKA Software GmbH
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
*/
const { idInput } = require('../../../utils/inputs');
const Errors = {
USER_NOT_FOUND: {
userNotFound: 'User not found',
},
DOES_NOT_EXIST: {
doesNotExist: 'User does not have an API key',
},
};
module.exports = {
inputs: {
id: {
...idInput,
required: true,
},
},
exits: {
userNotFound: {
responseType: 'notFound',
},
doesNotExist: {
responseType: 'notFound',
},
},
async fn(inputs) {
const { id } = inputs;
const { apiKey } = await sails.helpers.apiKey.createAndStore
.with({
id,
cycle: true,
})
.intercept('doesNotExist', () => Errors.DOES_NOT_EXIST)
.intercept('userNotFound', () => Errors.USER_NOT_FOUND);
return {
item: {
apiKey,
},
};
},
};

View file

@ -0,0 +1,50 @@
/*!
* Copyright (c) 2025 PLANKA Software GmbH
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
*/
const { idInput } = require('../../../utils/inputs');
const Errors = {
USER_NOT_FOUND: {
userNotFound: 'User not found',
},
DOES_NOT_EXIST: {
doesNotExist: 'User does not have an API key',
},
};
module.exports = {
inputs: {
id: {
...idInput,
required: true,
},
},
exits: {
userNotFound: {
responseType: 'notFound',
},
doesNotExist: {
responseType: 'notFound',
},
},
async fn(inputs) {
const { id } = inputs;
await sails.helpers.apiKey.deleteOne
.with({
id,
})
.intercept('doesNotExist', () => Errors.DOES_NOT_EXIST)
.intercept('userNotFound', () => Errors.USER_NOT_FOUND);
return {
item: {
success: true,
},
};
},
};