mirror of
https://github.com/plankanban/planka.git
synced 2025-07-20 13:49:43 +02:00
Add username to user
This commit is contained in:
parent
ec222a5e32
commit
af00e3e191
143 changed files with 1051 additions and 420 deletions
|
@ -10,10 +10,11 @@ module.exports = {
|
|||
},
|
||||
values: {
|
||||
type: 'json',
|
||||
custom: value =>
|
||||
custom: (value) =>
|
||||
_.isPlainObject(value) &&
|
||||
(_.isUndefined(value.email) || _.isString(value.email)) &&
|
||||
(_.isUndefined(value.password) || _.isString(value.password)),
|
||||
(_.isUndefined(value.password) || _.isString(value.password)) &&
|
||||
(!value.username || _.isString(value.username)),
|
||||
required: true,
|
||||
},
|
||||
request: {
|
||||
|
@ -22,7 +23,8 @@ module.exports = {
|
|||
},
|
||||
|
||||
exits: {
|
||||
conflict: {},
|
||||
emailAlreadyInUse: {},
|
||||
usernameAlreadyInUse: {},
|
||||
},
|
||||
|
||||
async fn(inputs, exits) {
|
||||
|
@ -42,6 +44,11 @@ module.exports = {
|
|||
}
|
||||
}
|
||||
|
||||
if (inputs.values.username) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
inputs.values.username = inputs.values.username.toLowerCase();
|
||||
}
|
||||
|
||||
const user = await User.updateOne({
|
||||
id: inputs.record.id,
|
||||
deletedAt: null,
|
||||
|
@ -52,7 +59,14 @@ module.exports = {
|
|||
message:
|
||||
'Unexpected error from database adapter: conflicting key value violates exclusion constraint "user_email_unique"',
|
||||
},
|
||||
'conflict',
|
||||
'emailAlreadyInUse',
|
||||
)
|
||||
.intercept(
|
||||
{
|
||||
message:
|
||||
'Unexpected error from database adapter: conflicting key value violates exclusion constraint "user_username_unique"',
|
||||
},
|
||||
'usernameAlreadyInUse',
|
||||
);
|
||||
|
||||
if (user) {
|
||||
|
@ -73,7 +87,7 @@ module.exports = {
|
|||
|
||||
const userIds = _.union([user.id], adminUserIds, userIdsForProject);
|
||||
|
||||
userIds.forEach(userId => {
|
||||
userIds.forEach((userId) => {
|
||||
sails.sockets.broadcast(
|
||||
`user:${userId}`,
|
||||
'userUpdate',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue