1
0
Fork 0
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:
Maksim Eltyshev 2022-12-26 21:10:50 +01:00
parent d39da61295
commit 5cd025ffb7
182 changed files with 1573 additions and 1239 deletions

View file

@ -9,6 +9,8 @@ const Errors = {
},
};
const passwordValidator = (value) => zxcvbn(value).score >= 2; // TODO: move to config
module.exports = {
inputs: {
email: {
@ -18,7 +20,7 @@ module.exports = {
},
password: {
type: 'string',
custom: (value) => zxcvbn(value).score >= 2, // TODO: move to config
custom: passwordValidator,
required: true,
},
name: {
@ -74,8 +76,11 @@ module.exports = {
'subscribeToOwnCards',
]);
const user = await sails.helpers.users
.createOne(values, this.req)
const user = await sails.helpers.users.createOne
.with({
values,
request: this.req,
})
.intercept('emailAlreadyInUse', () => Errors.EMAIL_ALREADY_IN_USE)
.intercept('usernameAlreadyInUse', () => Errors.USERNAME_ALREADY_IN_USE);

View file

@ -26,7 +26,10 @@ module.exports = {
throw Errors.USER_NOT_FOUND;
}
user = await sails.helpers.users.deleteOne(user, this.req);
user = await sails.helpers.users.deleteOne.with({
record: user,
request: this.req,
});
if (!user) {
throw Errors.USER_NOT_FOUND;

View file

@ -86,14 +86,14 @@ module.exports = {
return Errors.FILE_IS_NOT_IMAGE;
});
user = await sails.helpers.users.updateOne(
user,
{
user = await sails.helpers.users.updateOne.with({
record: user,
values: {
avatar: fileData,
},
currentUser,
this.req,
);
user: currentUser,
request: this.req,
});
if (!user) {
throw Errors.USER_NOT_FOUND;

View file

@ -68,8 +68,13 @@ module.exports = {
const values = _.pick(inputs, ['email']);
user = await sails.helpers.users
.updateOne(user, values, currentUser, this.req)
user = await sails.helpers.users.updateOne
.with({
values,
record: user,
user: currentUser,
request: this.req,
})
.intercept('emailAlreadyInUse', () => Errors.EMAIL_ALREADY_IN_USE);
if (!user) {

View file

@ -12,6 +12,8 @@ const Errors = {
},
};
const passwordValidator = (value) => zxcvbn(value).score >= 2; // TODO: move to config
module.exports = {
inputs: {
id: {
@ -21,7 +23,7 @@ module.exports = {
},
password: {
type: 'string',
custom: (value) => zxcvbn(value).score >= 2, // TODO: move to config
custom: passwordValidator,
required: true,
},
currentPassword: {
@ -64,7 +66,13 @@ module.exports = {
}
const values = _.pick(inputs, ['password']);
user = await sails.helpers.users.updateOne(user, values, currentUser, this.req);
user = await sails.helpers.users.updateOne.with({
values,
record: user,
user: currentUser,
request: this.req,
});
if (!user) {
throw Errors.USER_NOT_FOUND;

View file

@ -70,8 +70,13 @@ module.exports = {
const values = _.pick(inputs, ['username']);
user = await sails.helpers.users
.updateOne(user, values, currentUser, this.req)
user = await sails.helpers.users.updateOne
.with({
values,
record: user,
user: currentUser,
request: this.req,
})
.intercept('usernameAlreadyInUse', () => Errors.USERNAME_ALREADY_IN_USE);
if (!user) {

View file

@ -4,6 +4,8 @@ const Errors = {
},
};
const avatarUrlValidator = (value) => _.isNull(value);
module.exports = {
inputs: {
id: {
@ -20,7 +22,7 @@ module.exports = {
},
avatarUrl: {
type: 'json',
custom: (value) => _.isNull(value),
custom: avatarUrlValidator,
},
phone: {
type: 'string',
@ -77,7 +79,12 @@ module.exports = {
avatar: inputs.avatarUrl,
};
user = await sails.helpers.users.updateOne(user, values, currentUser, this.req);
user = await sails.helpers.users.updateOne.with({
values,
record: user,
user: currentUser,
request: this.req,
});
if (!user) {
throw Errors.USER_NOT_FOUND;