mirror of
https://github.com/plankanban/planka.git
synced 2025-07-19 05:09:43 +02:00
ref: Remove board types, refactoring
This commit is contained in:
parent
d39da61295
commit
5cd025ffb7
182 changed files with 1573 additions and 1239 deletions
|
@ -1,28 +1,30 @@
|
|||
const bcrypt = require('bcrypt');
|
||||
|
||||
const valuesValidator = (value) => {
|
||||
if (!_.isPlainObject(value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!_.isString(value.email)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!_.isString(value.password)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (value.username && !_.isString(value.username)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
inputs: {
|
||||
values: {
|
||||
type: 'json',
|
||||
custom: (value) => {
|
||||
if (!_.isPlainObject(value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!_.isString(value.email)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!_.isString(value.password)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (value.username && !_.isString(value.username)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
custom: valuesValidator,
|
||||
required: true,
|
||||
},
|
||||
request: {
|
||||
|
@ -36,15 +38,16 @@ module.exports = {
|
|||
},
|
||||
|
||||
async fn(inputs) {
|
||||
if (inputs.values.username) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
inputs.values.username = inputs.values.username.toLowerCase();
|
||||
const { values } = inputs;
|
||||
|
||||
if (values.username) {
|
||||
values.username = values.username.toLowerCase();
|
||||
}
|
||||
|
||||
const user = await User.create({
|
||||
...inputs.values,
|
||||
email: inputs.values.email.toLowerCase(),
|
||||
password: bcrypt.hashSync(inputs.values.password, 10),
|
||||
...values,
|
||||
email: values.email.toLowerCase(),
|
||||
password: bcrypt.hashSync(values.password, 10),
|
||||
})
|
||||
.intercept(
|
||||
{
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
const idOrIdsValidator = (value) => _.isString(value) || _.every(value, _.isString);
|
||||
|
||||
module.exports = {
|
||||
inputs: {
|
||||
idOrIds: {
|
||||
type: 'json',
|
||||
custom: (value) => _.isString(value) || _.every(value, _.isString),
|
||||
custom: idOrIdsValidator,
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
const idOrIdsValidator = (value) => _.isString(value) || _.every(value, _.isString);
|
||||
|
||||
module.exports = {
|
||||
inputs: {
|
||||
idOrIds: {
|
||||
type: 'json',
|
||||
custom: (value) => _.isString(value) || _.every(value, _.isString),
|
||||
custom: idOrIdsValidator,
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
const criteriaValidator = (value) => _.isArray(value) || _.isPlainObject(value);
|
||||
|
||||
module.exports = {
|
||||
inputs: {
|
||||
criteria: {
|
||||
type: 'json',
|
||||
custom: (value) => _.isArray(value) || _.isPlainObject(value),
|
||||
custom: criteriaValidator,
|
||||
},
|
||||
withDeleted: {
|
||||
type: 'boolean',
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
const idOrIdsValidator = (value) => _.isString(value) || _.every(value, _.isString);
|
||||
|
||||
module.exports = {
|
||||
inputs: {
|
||||
idOrIds: {
|
||||
type: 'json',
|
||||
custom: (value) => _.isString(value) || _.every(value, _.isString),
|
||||
custom: idOrIdsValidator,
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
const idOrIdsValidator = (value) => _.isString(value) || _.every(value, _.isString);
|
||||
|
||||
module.exports = {
|
||||
inputs: {
|
||||
idOrIds: {
|
||||
type: 'json',
|
||||
custom: (value) => _.isString(value) || _.every(value, _.isString),
|
||||
custom: idOrIdsValidator,
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
const criteriaValidator = (value) => _.isString(value) || _.isPlainObject(value);
|
||||
|
||||
module.exports = {
|
||||
inputs: {
|
||||
criteria: {
|
||||
type: 'json',
|
||||
custom: (value) => _.isString(value) || _.isPlainObject(value),
|
||||
custom: criteriaValidator,
|
||||
required: true,
|
||||
},
|
||||
withDeleted: {
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
const idOrIdsValidator = (value) => _.isString(value) || _.every(value, _.isString);
|
||||
|
||||
module.exports = {
|
||||
inputs: {
|
||||
idOrIds: {
|
||||
type: 'json',
|
||||
custom: (value) => _.isString(value) || _.every(value, _.isString),
|
||||
custom: idOrIdsValidator,
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
|
|
|
@ -3,6 +3,30 @@ const bcrypt = require('bcrypt');
|
|||
const rimraf = require('rimraf');
|
||||
const { v4: uuid } = require('uuid');
|
||||
|
||||
const valuesValidator = (value) => {
|
||||
if (!_.isPlainObject(value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!_.isUndefined(value.email) && !_.isString(value.email)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!_.isUndefined(value.password) && !_.isString(value.password)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (value.username && !_.isString(value.username)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (value.avatar && !_.isPlainObject(value.avatar)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
inputs: {
|
||||
record: {
|
||||
|
@ -11,29 +35,7 @@ module.exports = {
|
|||
},
|
||||
values: {
|
||||
type: 'json',
|
||||
custom: (value) => {
|
||||
if (!_.isPlainObject(value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!_.isUndefined(value.email) && !_.isString(value.email)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!_.isUndefined(value.password) && !_.isString(value.password)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (value.username && !_.isString(value.username)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (value.avatar && !_.isPlainObject(value.avatar)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
custom: valuesValidator,
|
||||
required: true,
|
||||
},
|
||||
user: {
|
||||
|
@ -51,34 +53,34 @@ module.exports = {
|
|||
},
|
||||
|
||||
async fn(inputs) {
|
||||
if (!_.isUndefined(inputs.values.email)) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
inputs.values.email = inputs.values.email.toLowerCase();
|
||||
const { values } = inputs;
|
||||
|
||||
if (!_.isUndefined(values.email)) {
|
||||
values.email = values.email.toLowerCase();
|
||||
}
|
||||
|
||||
let isOnlyPasswordChange = false;
|
||||
|
||||
if (!_.isUndefined(inputs.values.password)) {
|
||||
Object.assign(inputs.values, {
|
||||
password: bcrypt.hashSync(inputs.values.password, 10),
|
||||
if (!_.isUndefined(values.password)) {
|
||||
Object.assign(values, {
|
||||
password: bcrypt.hashSync(values.password, 10),
|
||||
passwordChangedAt: new Date().toUTCString(),
|
||||
});
|
||||
|
||||
if (Object.keys(inputs.values).length === 1) {
|
||||
if (Object.keys(values).length === 1) {
|
||||
isOnlyPasswordChange = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (inputs.values.username) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
inputs.values.username = inputs.values.username.toLowerCase();
|
||||
if (values.username) {
|
||||
values.username = values.username.toLowerCase();
|
||||
}
|
||||
|
||||
const user = await User.updateOne({
|
||||
id: inputs.record.id,
|
||||
deletedAt: null,
|
||||
})
|
||||
.set(inputs.values)
|
||||
.set({ ...values })
|
||||
.intercept(
|
||||
{
|
||||
message:
|
||||
|
@ -106,7 +108,7 @@ module.exports = {
|
|||
}
|
||||
}
|
||||
|
||||
if (!_.isUndefined(inputs.values.password)) {
|
||||
if (!_.isUndefined(values.password)) {
|
||||
sails.sockets.broadcast(
|
||||
`user:${user.id}`,
|
||||
'userDelete', // TODO: introduce separate event
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue