mirror of
https://github.com/plankanban/planka.git
synced 2025-07-24 15:49:46 +02:00
Add username to user
This commit is contained in:
parent
ec222a5e32
commit
af00e3e191
143 changed files with 1051 additions and 420 deletions
|
@ -35,7 +35,7 @@ module.exports = {
|
|||
|
||||
const userIds = await sails.helpers.getSubscriptionUserIdsForCard(action.cardId, action.userId);
|
||||
|
||||
userIds.forEach(async userId => {
|
||||
userIds.forEach(async (userId) => {
|
||||
const notification = await Notification.create({
|
||||
userId,
|
||||
actionId: action.id,
|
||||
|
|
|
@ -6,7 +6,7 @@ module.exports = {
|
|||
},
|
||||
values: {
|
||||
type: 'json',
|
||||
custom: value => _.isPlainObject(value) && _.isFinite(value.position),
|
||||
custom: (value) => _.isPlainObject(value) && _.isFinite(value.position),
|
||||
required: true,
|
||||
},
|
||||
request: {
|
||||
|
@ -32,7 +32,7 @@ module.exports = {
|
|||
position: nextPosition,
|
||||
});
|
||||
|
||||
userIds.forEach(userId => {
|
||||
userIds.forEach((userId) => {
|
||||
sails.sockets.broadcast(`user:${userId}`, 'boardUpdate', {
|
||||
item: {
|
||||
id,
|
||||
|
@ -48,7 +48,7 @@ module.exports = {
|
|||
projectId: inputs.project.id,
|
||||
}).fetch();
|
||||
|
||||
userIds.forEach(userId => {
|
||||
userIds.forEach((userId) => {
|
||||
sails.sockets.broadcast(
|
||||
`user:${userId}`,
|
||||
'boardCreate',
|
||||
|
|
|
@ -13,12 +13,16 @@ module.exports = {
|
|||
},
|
||||
},
|
||||
|
||||
exits: {
|
||||
labelAlreadyInCard: {},
|
||||
},
|
||||
|
||||
async fn(inputs, exits) {
|
||||
const cardLabel = await CardLabel.create({
|
||||
cardId: inputs.card.id,
|
||||
labelId: inputs.label.id,
|
||||
})
|
||||
.intercept('E_UNIQUE', 'conflict')
|
||||
.intercept('E_UNIQUE', 'labelAlreadyInCard')
|
||||
.fetch();
|
||||
|
||||
sails.sockets.broadcast(
|
||||
|
|
|
@ -6,7 +6,7 @@ module.exports = {
|
|||
},
|
||||
userOrUserId: {
|
||||
type: 'ref',
|
||||
custom: value => _.isPlainObject(value) || _.isString(value),
|
||||
custom: (value) => _.isPlainObject(value) || _.isString(value),
|
||||
required: true,
|
||||
},
|
||||
request: {
|
||||
|
@ -14,6 +14,10 @@ module.exports = {
|
|||
},
|
||||
},
|
||||
|
||||
exits: {
|
||||
userAlreadyCardMember: {},
|
||||
},
|
||||
|
||||
async fn(inputs, exits) {
|
||||
const { userId = inputs.userOrUserId } = inputs.userOrUserId;
|
||||
|
||||
|
@ -21,7 +25,7 @@ module.exports = {
|
|||
userId,
|
||||
cardId: inputs.card.id,
|
||||
})
|
||||
.intercept('E_UNIQUE', 'conflict')
|
||||
.intercept('E_UNIQUE', 'userAlreadyCardMember')
|
||||
.fetch();
|
||||
|
||||
sails.sockets.broadcast(
|
||||
|
|
|
@ -6,7 +6,7 @@ module.exports = {
|
|||
},
|
||||
values: {
|
||||
type: 'json',
|
||||
custom: value => _.isPlainObject(value) && _.isFinite(value.position),
|
||||
custom: (value) => _.isPlainObject(value) && _.isFinite(value.position),
|
||||
required: true,
|
||||
},
|
||||
user: {
|
||||
|
|
|
@ -6,7 +6,7 @@ module.exports = {
|
|||
},
|
||||
values: {
|
||||
type: 'json',
|
||||
custom: value => _.isPlainObject(value) && _.isFinite(value.position),
|
||||
custom: (value) => _.isPlainObject(value) && _.isFinite(value.position),
|
||||
required: true,
|
||||
},
|
||||
request: {
|
||||
|
|
|
@ -14,7 +14,7 @@ module.exports = {
|
|||
},
|
||||
|
||||
exits: {
|
||||
conflict: {},
|
||||
userAlreadyProjectMember: {},
|
||||
},
|
||||
|
||||
async fn(inputs, exits) {
|
||||
|
@ -22,7 +22,7 @@ module.exports = {
|
|||
projectId: inputs.project.id,
|
||||
userId: inputs.user.id,
|
||||
})
|
||||
.intercept('E_UNIQUE', 'conflict')
|
||||
.intercept('E_UNIQUE', 'userAlreadyProjectMember')
|
||||
.fetch();
|
||||
|
||||
const { userIds, projectMemberships } = await sails.helpers.getMembershipUserIdsForProject(
|
||||
|
@ -30,7 +30,7 @@ module.exports = {
|
|||
true,
|
||||
);
|
||||
|
||||
userIds.forEach(userId => {
|
||||
userIds.forEach((userId) => {
|
||||
if (userId !== projectMembership.userId) {
|
||||
sails.sockets.broadcast(
|
||||
`user:${userId}`,
|
||||
|
|
|
@ -4,8 +4,11 @@ module.exports = {
|
|||
inputs: {
|
||||
values: {
|
||||
type: 'json',
|
||||
custom: value =>
|
||||
_.isPlainObject(value) && _.isString(value.email) && _.isString(value.password),
|
||||
custom: (value) =>
|
||||
_.isPlainObject(value) &&
|
||||
_.isString(value.email) &&
|
||||
_.isString(value.password) &&
|
||||
(!value.username || _.isString(value.username)),
|
||||
required: true,
|
||||
},
|
||||
request: {
|
||||
|
@ -14,10 +17,16 @@ module.exports = {
|
|||
},
|
||||
|
||||
exits: {
|
||||
conflict: {},
|
||||
emailAlreadyInUse: {},
|
||||
usernameAlreadyInUse: {},
|
||||
},
|
||||
|
||||
async fn(inputs, exits) {
|
||||
if (inputs.values.username) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
inputs.values.username = inputs.values.username.toLowerCase();
|
||||
}
|
||||
|
||||
const user = await User.create({
|
||||
...inputs.values,
|
||||
email: inputs.values.email.toLowerCase(),
|
||||
|
@ -28,13 +37,20 @@ 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',
|
||||
)
|
||||
.fetch();
|
||||
|
||||
const userIds = await sails.helpers.getAdminUserIds();
|
||||
|
||||
userIds.forEach(userId => {
|
||||
userIds.forEach((userId) => {
|
||||
sails.sockets.broadcast(
|
||||
`user:${userId}`,
|
||||
'userCreate',
|
||||
|
|
|
@ -17,7 +17,7 @@ module.exports = {
|
|||
|
||||
const userIds = await sails.helpers.getMembershipUserIdsForProject(board.projectId);
|
||||
|
||||
userIds.forEach(userId => {
|
||||
userIds.forEach((userId) => {
|
||||
sails.sockets.broadcast(
|
||||
`user:${userId}`,
|
||||
'boardDelete',
|
||||
|
|
|
@ -34,7 +34,7 @@ module.exports = {
|
|||
projectMembership.projectId,
|
||||
);
|
||||
|
||||
userIds.forEach(userId => {
|
||||
userIds.forEach((userId) => {
|
||||
sails.sockets.broadcast(
|
||||
`user:${userId}`,
|
||||
'projectMembershipDelete',
|
||||
|
@ -47,7 +47,7 @@ module.exports = {
|
|||
|
||||
sails.sockets.removeRoomMembersFromRooms(
|
||||
`user:${projectMembership.userId}`,
|
||||
boardIds.map(boardId => `board:${boardId}`),
|
||||
boardIds.map((boardId) => `board:${boardId}`),
|
||||
);
|
||||
|
||||
const project = await Project.findOne(projectMembership.projectId);
|
||||
|
|
|
@ -20,9 +20,9 @@ module.exports = {
|
|||
const userIds = sails.helpers.mapRecords(projectMemberships, 'userId');
|
||||
|
||||
const boards = await sails.helpers.getBoardsForProject(project.id);
|
||||
const boardRooms = boards.map(board => `board:${board.id}`);
|
||||
const boardRooms = boards.map((board) => `board:${board.id}`);
|
||||
|
||||
userIds.forEach(userId => {
|
||||
userIds.forEach((userId) => {
|
||||
sails.sockets.removeRoomMembersFromRooms(`user:${userId}`, boardRooms);
|
||||
|
||||
sails.sockets.broadcast(
|
||||
|
|
|
@ -38,7 +38,7 @@ module.exports = {
|
|||
|
||||
const userIds = _.union([user.id], adminUserIds, userIdsForProject);
|
||||
|
||||
userIds.forEach(userId => {
|
||||
userIds.forEach((userId) => {
|
||||
sails.sockets.broadcast(
|
||||
`user:${userId}`,
|
||||
'userDelete',
|
||||
|
|
|
@ -7,20 +7,20 @@ module.exports = {
|
|||
},
|
||||
|
||||
exits: {
|
||||
notFound: {},
|
||||
pathNotFound: {},
|
||||
},
|
||||
|
||||
async fn(inputs, exits) {
|
||||
const action = await Action.findOne(inputs.criteria);
|
||||
|
||||
if (!action) {
|
||||
throw 'notFound';
|
||||
throw 'pathNotFound';
|
||||
}
|
||||
|
||||
const path = await sails.helpers
|
||||
.getCardToProjectPath(action.cardId)
|
||||
.intercept('notFound', nodes => ({
|
||||
notFound: {
|
||||
.intercept('pathNotFound', (nodes) => ({
|
||||
pathNotFound: {
|
||||
action,
|
||||
...nodes,
|
||||
},
|
||||
|
|
|
@ -4,7 +4,7 @@ module.exports = {
|
|||
inputs: {
|
||||
id: {
|
||||
type: 'json',
|
||||
custom: value => _.isString(value) || _.isArray(value),
|
||||
custom: (value) => _.isString(value) || _.isArray(value),
|
||||
required: true,
|
||||
},
|
||||
beforeId: {
|
||||
|
|
|
@ -2,7 +2,7 @@ module.exports = {
|
|||
inputs: {
|
||||
criteria: {
|
||||
type: 'json',
|
||||
custom: value => _.isArray(value) || _.isPlainObject(value),
|
||||
custom: (value) => _.isArray(value) || _.isPlainObject(value),
|
||||
},
|
||||
limit: {
|
||||
type: 'number',
|
||||
|
@ -10,9 +10,7 @@ module.exports = {
|
|||
},
|
||||
|
||||
async fn(inputs, exits) {
|
||||
const actions = await Action.find(inputs.criteria)
|
||||
.sort('id DESC')
|
||||
.limit(inputs.limit);
|
||||
const actions = await Action.find(inputs.criteria).sort('id DESC').limit(inputs.limit);
|
||||
|
||||
return exits.success(actions);
|
||||
},
|
||||
|
|
|
@ -7,21 +7,21 @@ module.exports = {
|
|||
},
|
||||
|
||||
exits: {
|
||||
notFound: {},
|
||||
pathNotFound: {},
|
||||
},
|
||||
|
||||
async fn(inputs, exits) {
|
||||
const board = await Board.findOne(inputs.criteria);
|
||||
|
||||
if (!board) {
|
||||
throw 'notFound';
|
||||
throw 'pathNotFound';
|
||||
}
|
||||
|
||||
const project = await Project.findOne(board.projectId);
|
||||
|
||||
if (!project) {
|
||||
throw {
|
||||
notFound: {
|
||||
pathNotFound: {
|
||||
board,
|
||||
},
|
||||
};
|
||||
|
|
|
@ -2,12 +2,12 @@ module.exports = {
|
|||
inputs: {
|
||||
id: {
|
||||
type: 'json',
|
||||
custom: value => _.isString(value) || _.isArray(value),
|
||||
custom: (value) => _.isString(value) || _.isArray(value),
|
||||
required: true,
|
||||
},
|
||||
exceptBoardId: {
|
||||
type: 'json',
|
||||
custom: value => _.isString(value) || _.isArray(value),
|
||||
custom: (value) => _.isString(value) || _.isArray(value),
|
||||
},
|
||||
},
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ module.exports = {
|
|||
inputs: {
|
||||
criteria: {
|
||||
type: 'json',
|
||||
custom: value => _.isArray(value) || _.isPlainObject(value),
|
||||
custom: (value) => _.isArray(value) || _.isPlainObject(value),
|
||||
},
|
||||
},
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ module.exports = {
|
|||
inputs: {
|
||||
id: {
|
||||
type: 'json',
|
||||
custom: value => _.isString(value) || _.isArray(value),
|
||||
custom: (value) => _.isString(value) || _.isArray(value),
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
|
|
|
@ -2,7 +2,7 @@ module.exports = {
|
|||
inputs: {
|
||||
criteria: {
|
||||
type: 'json',
|
||||
custom: value => _.isArray(value) || _.isPlainObject(value),
|
||||
custom: (value) => _.isArray(value) || _.isPlainObject(value),
|
||||
},
|
||||
},
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ module.exports = {
|
|||
inputs: {
|
||||
criteria: {
|
||||
type: 'json',
|
||||
custom: value => _.isArray(value) || _.isPlainObject(value),
|
||||
custom: (value) => _.isArray(value) || _.isPlainObject(value),
|
||||
},
|
||||
},
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ module.exports = {
|
|||
inputs: {
|
||||
criteria: {
|
||||
type: 'json',
|
||||
custom: value => _.isArray(value) || _.isPlainObject(value),
|
||||
custom: (value) => _.isArray(value) || _.isPlainObject(value),
|
||||
},
|
||||
},
|
||||
|
||||
|
|
|
@ -7,20 +7,20 @@ module.exports = {
|
|||
},
|
||||
|
||||
exits: {
|
||||
notFound: {},
|
||||
pathNotFound: {},
|
||||
},
|
||||
|
||||
async fn(inputs, exits) {
|
||||
const card = await Card.findOne(inputs.criteria);
|
||||
|
||||
if (!card) {
|
||||
throw 'notFound';
|
||||
throw 'pathNotFound';
|
||||
}
|
||||
|
||||
const path = await sails.helpers
|
||||
.getListToProjectPath(card.listId)
|
||||
.intercept('notFound', nodes => ({
|
||||
notFound: {
|
||||
.intercept('pathNotFound', (nodes) => ({
|
||||
pathNotFound: {
|
||||
card,
|
||||
...nodes,
|
||||
},
|
||||
|
|
|
@ -2,7 +2,7 @@ module.exports = {
|
|||
inputs: {
|
||||
id: {
|
||||
type: 'json',
|
||||
custom: value => _.isString(value) || _.isArray(value),
|
||||
custom: (value) => _.isString(value) || _.isArray(value),
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
|
|
|
@ -2,12 +2,12 @@ module.exports = {
|
|||
inputs: {
|
||||
id: {
|
||||
type: 'json',
|
||||
custom: value => _.isString(value) || _.isArray(value),
|
||||
custom: (value) => _.isString(value) || _.isArray(value),
|
||||
required: true,
|
||||
},
|
||||
exceptCardId: {
|
||||
type: 'json',
|
||||
custom: value => _.isString(value) || _.isArray(value),
|
||||
custom: (value) => _.isString(value) || _.isArray(value),
|
||||
},
|
||||
},
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ module.exports = {
|
|||
inputs: {
|
||||
criteria: {
|
||||
type: 'json',
|
||||
custom: value => _.isArray(value) || _.isPlainObject(value),
|
||||
custom: (value) => _.isArray(value) || _.isPlainObject(value),
|
||||
},
|
||||
},
|
||||
|
||||
|
|
|
@ -7,20 +7,20 @@ module.exports = {
|
|||
},
|
||||
|
||||
exits: {
|
||||
notFound: {},
|
||||
pathNotFound: {},
|
||||
},
|
||||
|
||||
async fn(inputs, exits) {
|
||||
const label = await Label.findOne(inputs.criteria);
|
||||
|
||||
if (!label) {
|
||||
throw 'notFound';
|
||||
throw 'pathNotFound';
|
||||
}
|
||||
|
||||
const path = await sails.helpers
|
||||
.getBoardToProjectPath(label.boardId)
|
||||
.intercept('notFound', nodes => ({
|
||||
notFound: {
|
||||
.intercept('pathNotFound', (nodes) => ({
|
||||
pathNotFound: {
|
||||
label,
|
||||
...nodes,
|
||||
},
|
||||
|
|
|
@ -2,7 +2,7 @@ module.exports = {
|
|||
inputs: {
|
||||
id: {
|
||||
type: 'json',
|
||||
custom: value => _.isString(value) || _.isArray(value),
|
||||
custom: (value) => _.isString(value) || _.isArray(value),
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
|
|
|
@ -7,20 +7,20 @@ module.exports = {
|
|||
},
|
||||
|
||||
exits: {
|
||||
notFound: {},
|
||||
pathNotFound: {},
|
||||
},
|
||||
|
||||
async fn(inputs, exits) {
|
||||
const list = await List.findOne(inputs.criteria);
|
||||
|
||||
if (!list) {
|
||||
throw 'notFound';
|
||||
throw 'pathNotFound';
|
||||
}
|
||||
|
||||
const path = await sails.helpers
|
||||
.getBoardToProjectPath(list.boardId)
|
||||
.intercept('notFound', nodes => ({
|
||||
notFound: {
|
||||
.intercept('pathNotFound', (nodes) => ({
|
||||
pathNotFound: {
|
||||
list,
|
||||
...nodes,
|
||||
},
|
||||
|
|
|
@ -2,12 +2,12 @@ module.exports = {
|
|||
inputs: {
|
||||
id: {
|
||||
type: 'json',
|
||||
custom: value => _.isString(value) || _.isArray(value),
|
||||
custom: (value) => _.isString(value) || _.isArray(value),
|
||||
required: true,
|
||||
},
|
||||
exceptListId: {
|
||||
type: 'json',
|
||||
custom: value => _.isString(value) || _.isArray(value),
|
||||
custom: (value) => _.isString(value) || _.isArray(value),
|
||||
},
|
||||
},
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ module.exports = {
|
|||
inputs: {
|
||||
id: {
|
||||
type: 'json',
|
||||
custom: value => _.isString(value) || _.isArray(value),
|
||||
custom: (value) => _.isString(value) || _.isArray(value),
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
|
|
|
@ -2,7 +2,7 @@ module.exports = {
|
|||
inputs: {
|
||||
id: {
|
||||
type: 'json',
|
||||
custom: value => _.isString(value) || _.isArray(value),
|
||||
custom: (value) => _.isString(value) || _.isArray(value),
|
||||
required: true,
|
||||
},
|
||||
withProjectMemberships: {
|
||||
|
|
|
@ -2,12 +2,12 @@ module.exports = {
|
|||
inputs: {
|
||||
id: {
|
||||
type: 'json',
|
||||
custom: value => _.isString(value) || _.isArray(value),
|
||||
custom: (value) => _.isString(value) || _.isArray(value),
|
||||
required: true,
|
||||
},
|
||||
exceptUserId: {
|
||||
type: 'json',
|
||||
custom: value => _.isString(value) || _.isArray(value),
|
||||
custom: (value) => _.isString(value) || _.isArray(value),
|
||||
},
|
||||
},
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ module.exports = {
|
|||
inputs: {
|
||||
id: {
|
||||
type: 'json',
|
||||
custom: value => _.isString(value) || _.isArray(value),
|
||||
custom: (value) => _.isString(value) || _.isArray(value),
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
|
|
|
@ -2,7 +2,7 @@ module.exports = {
|
|||
inputs: {
|
||||
id: {
|
||||
type: 'json',
|
||||
custom: value => _.isString(value) || _.isArray(value),
|
||||
custom: (value) => _.isString(value) || _.isArray(value),
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
|
|
|
@ -2,7 +2,7 @@ module.exports = {
|
|||
inputs: {
|
||||
criteria: {
|
||||
type: 'json',
|
||||
custom: value => _.isArray(value) || _.isPlainObject(value),
|
||||
custom: (value) => _.isArray(value) || _.isPlainObject(value),
|
||||
},
|
||||
},
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ module.exports = {
|
|||
inputs: {
|
||||
id: {
|
||||
type: 'json',
|
||||
custom: value => _.isString(value) || _.isArray(value),
|
||||
custom: (value) => _.isString(value) || _.isArray(value),
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
|
|
|
@ -2,7 +2,7 @@ module.exports = {
|
|||
inputs: {
|
||||
criteria: {
|
||||
type: 'json',
|
||||
custom: value => _.isArray(value) || _.isPlainObject(value),
|
||||
custom: (value) => _.isArray(value) || _.isPlainObject(value),
|
||||
},
|
||||
},
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ module.exports = {
|
|||
inputs: {
|
||||
criteria: {
|
||||
type: 'json',
|
||||
custom: value => _.isArray(value) || _.isPlainObject(value),
|
||||
custom: (value) => _.isArray(value) || _.isPlainObject(value),
|
||||
},
|
||||
},
|
||||
|
||||
|
|
|
@ -2,12 +2,12 @@ module.exports = {
|
|||
inputs: {
|
||||
id: {
|
||||
type: 'json',
|
||||
custom: value => _.isString(value) || _.isArray(value),
|
||||
custom: (value) => _.isString(value) || _.isArray(value),
|
||||
required: true,
|
||||
},
|
||||
exceptUserId: {
|
||||
type: 'json',
|
||||
custom: value => _.isString(value) || _.isArray(value),
|
||||
custom: (value) => _.isString(value) || _.isArray(value),
|
||||
},
|
||||
withCardSubscriptions: {
|
||||
type: 'boolean',
|
||||
|
|
|
@ -2,7 +2,7 @@ module.exports = {
|
|||
inputs: {
|
||||
id: {
|
||||
type: 'json',
|
||||
custom: value => _.isString(value) || _.isArray(value),
|
||||
custom: (value) => _.isString(value) || _.isArray(value),
|
||||
required: true,
|
||||
},
|
||||
userId: {
|
||||
|
|
|
@ -2,12 +2,12 @@ module.exports = {
|
|||
inputs: {
|
||||
id: {
|
||||
type: 'json',
|
||||
custom: value => _.isString(value) || _.isArray(value),
|
||||
custom: (value) => _.isString(value) || _.isArray(value),
|
||||
required: true,
|
||||
},
|
||||
exceptUserId: {
|
||||
type: 'json',
|
||||
custom: value => _.isString(value) || _.isArray(value),
|
||||
custom: (value) => _.isString(value) || _.isArray(value),
|
||||
},
|
||||
},
|
||||
|
||||
|
|
|
@ -7,20 +7,20 @@ module.exports = {
|
|||
},
|
||||
|
||||
exits: {
|
||||
notFound: {},
|
||||
pathNotFound: {},
|
||||
},
|
||||
|
||||
async fn(inputs, exits) {
|
||||
const task = await Task.findOne(inputs.criteria);
|
||||
|
||||
if (!task) {
|
||||
throw 'notFound';
|
||||
throw 'pathNotFound';
|
||||
}
|
||||
|
||||
const path = await sails.helpers
|
||||
.getCardToProjectPath(task.cardId)
|
||||
.intercept('notFound', nodes => ({
|
||||
notFound: {
|
||||
.intercept('pathNotFound', (nodes) => ({
|
||||
pathNotFound: {
|
||||
task,
|
||||
...nodes,
|
||||
},
|
||||
|
|
|
@ -2,7 +2,7 @@ module.exports = {
|
|||
inputs: {
|
||||
id: {
|
||||
type: 'json',
|
||||
custom: value => _.isString(value) || _.isArray(value),
|
||||
custom: (value) => _.isString(value) || _.isArray(value),
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
|
|
|
@ -2,7 +2,7 @@ module.exports = {
|
|||
inputs: {
|
||||
criteria: {
|
||||
type: 'json',
|
||||
custom: value => _.isArray(value) || _.isPlainObject(value),
|
||||
custom: (value) => _.isArray(value) || _.isPlainObject(value),
|
||||
},
|
||||
},
|
||||
|
||||
|
|
18
server/api/helpers/get-user-by-email-or-username.js
Normal file
18
server/api/helpers/get-user-by-email-or-username.js
Normal file
|
@ -0,0 +1,18 @@
|
|||
module.exports = {
|
||||
inputs: {
|
||||
emailOrUsername: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
|
||||
async fn(inputs, exits) {
|
||||
const fieldName = inputs.emailOrUsername.includes('@') ? 'email' : 'username';
|
||||
|
||||
const user = await sails.helpers.getUser({
|
||||
[fieldName]: inputs.emailOrUsername.toLowerCase(),
|
||||
});
|
||||
|
||||
return exits.success(user);
|
||||
},
|
||||
};
|
|
@ -2,7 +2,7 @@ module.exports = {
|
|||
inputs: {
|
||||
criteria: {
|
||||
type: 'json',
|
||||
custom: value => _.isString(value) || _.isPlainObject(value),
|
||||
custom: (value) => _.isString(value) || _.isPlainObject(value),
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
|
|
|
@ -2,7 +2,7 @@ module.exports = {
|
|||
inputs: {
|
||||
criteria: {
|
||||
type: 'json',
|
||||
custom: value => _.isArray(value) || _.isPlainObject(value),
|
||||
custom: (value) => _.isArray(value) || _.isPlainObject(value),
|
||||
},
|
||||
},
|
||||
|
||||
|
|
|
@ -2,14 +2,14 @@ const GAP = 2 ** 14;
|
|||
const MIN_GAP = 0.125;
|
||||
const MAX_POSITION = 2 ** 50;
|
||||
|
||||
const findBeginnings = positions => {
|
||||
const findBeginnings = (positions) => {
|
||||
positions.unshift(0);
|
||||
|
||||
let prevPosition = positions.pop();
|
||||
const beginnings = [prevPosition];
|
||||
|
||||
// eslint-disable-next-line consistent-return
|
||||
_.forEachRight(positions, position => {
|
||||
_.forEachRight(positions, (position) => {
|
||||
if (prevPosition - MIN_GAP >= position) {
|
||||
return false;
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ const findBeginnings = positions => {
|
|||
return beginnings;
|
||||
};
|
||||
|
||||
const getRepositionsMap = positions => {
|
||||
const getRepositionsMap = (positions) => {
|
||||
const repositionsMap = {};
|
||||
|
||||
if (positions.length <= 1) {
|
||||
|
@ -62,7 +62,7 @@ const getRepositionsMap = positions => {
|
|||
return repositionsMap;
|
||||
};
|
||||
|
||||
const getFullRepositionsMap = positions => {
|
||||
const getFullRepositionsMap = (positions) => {
|
||||
const repositionsMap = {};
|
||||
|
||||
_.forEach(positions, (position, index) => {
|
||||
|
|
|
@ -4,7 +4,7 @@ module.exports = {
|
|||
inputs: {
|
||||
records: {
|
||||
type: 'ref',
|
||||
custom: value => _.isArray(value),
|
||||
custom: (value) => _.isArray(value),
|
||||
required: true,
|
||||
},
|
||||
attribute: {
|
||||
|
|
|
@ -6,7 +6,7 @@ module.exports = {
|
|||
},
|
||||
values: {
|
||||
type: 'json',
|
||||
custom: value =>
|
||||
custom: (value) =>
|
||||
_.isPlainObject(value) && (_.isUndefined(value.position) || _.isFinite(value.position)),
|
||||
required: true,
|
||||
},
|
||||
|
@ -39,7 +39,7 @@ module.exports = {
|
|||
position: nextPosition,
|
||||
});
|
||||
|
||||
userIds.forEach(userId => {
|
||||
userIds.forEach((userId) => {
|
||||
sails.sockets.broadcast(`user:${userId}`, 'boardUpdate', {
|
||||
item: {
|
||||
id,
|
||||
|
@ -53,7 +53,7 @@ module.exports = {
|
|||
const board = await Board.updateOne(inputs.record.id).set(inputs.values);
|
||||
|
||||
if (board) {
|
||||
userIds.forEach(userId => {
|
||||
userIds.forEach((userId) => {
|
||||
sails.sockets.broadcast(
|
||||
`user:${userId}`,
|
||||
'boardUpdate',
|
||||
|
|
|
@ -6,7 +6,7 @@ module.exports = {
|
|||
},
|
||||
values: {
|
||||
type: 'json',
|
||||
custom: value =>
|
||||
custom: (value) =>
|
||||
_.isPlainObject(value) && (_.isUndefined(value.position) || _.isFinite(value.position)),
|
||||
required: true,
|
||||
},
|
||||
|
|
|
@ -6,7 +6,7 @@ module.exports = {
|
|||
},
|
||||
values: {
|
||||
type: 'json',
|
||||
custom: value =>
|
||||
custom: (value) =>
|
||||
_.isPlainObject(value) && (_.isUndefined(value.position) || _.isFinite(value.position)),
|
||||
required: true,
|
||||
},
|
||||
|
|
|
@ -2,7 +2,7 @@ module.exports = {
|
|||
inputs: {
|
||||
ids: {
|
||||
type: 'json',
|
||||
custom: value => _.isArray(value),
|
||||
custom: (value) => _.isArray(value),
|
||||
required: true,
|
||||
},
|
||||
user: {
|
||||
|
@ -26,7 +26,7 @@ module.exports = {
|
|||
.set(inputs.values)
|
||||
.fetch();
|
||||
|
||||
notifications.forEach(notification => {
|
||||
notifications.forEach((notification) => {
|
||||
sails.sockets.broadcast(
|
||||
`user:${notification.userId}`,
|
||||
'notificationUpdate',
|
||||
|
|
|
@ -19,7 +19,7 @@ module.exports = {
|
|||
if (project) {
|
||||
const userIds = await sails.helpers.getMembershipUserIdsForProject(project.id);
|
||||
|
||||
userIds.forEach(userId => {
|
||||
userIds.forEach((userId) => {
|
||||
sails.sockets.broadcast(
|
||||
`user:${userId}`,
|
||||
'projectUpdate',
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -11,7 +11,7 @@ module.exports = {
|
|||
},
|
||||
|
||||
exits: {
|
||||
notValid: {},
|
||||
invalidToken: {},
|
||||
},
|
||||
|
||||
fn(inputs, exits) {
|
||||
|
@ -20,7 +20,7 @@ module.exports = {
|
|||
try {
|
||||
payload = jwt.verify(inputs.token, sails.config.session.secret);
|
||||
} catch (error) {
|
||||
throw 'notValid';
|
||||
throw 'invalidToken';
|
||||
}
|
||||
|
||||
return exits.success(payload);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue