diff --git a/packages/component-user-manager/src/CollectionsUsers.js b/packages/component-user-manager/src/CollectionsUsers.js index 28d5689915169d932ef91f6cf620b53f795bc886..8258226387f677c4a30c64643b15fded95ed1ef8 100644 --- a/packages/component-user-manager/src/CollectionsUsers.js +++ b/packages/component-user-manager/src/CollectionsUsers.js @@ -111,7 +111,10 @@ const CollectionsUsers = app => { * @apiParamExample {json} Body * { * "isSubmitting": false, - * "isCorresponding": true + * "isCorresponding": true, + * "firstName": "John", + * "lastName": "Smith", + * "affiliation": "UCLA" * } * @apiSuccessExample {json} Success * HTTP/1.1 200 OK diff --git a/packages/component-user-manager/src/routes/collectionsUsers/delete.js b/packages/component-user-manager/src/routes/collectionsUsers/delete.js index db4cdb7c444ac488ad5eebbeed85d5823d96a59a..2fae5bea551fdb6795c0fa0224a0d9f935f59e68 100644 --- a/packages/component-user-manager/src/routes/collectionsUsers/delete.js +++ b/packages/component-user-manager/src/routes/collectionsUsers/delete.js @@ -20,6 +20,7 @@ module.exports = models => async (req, res) => { await collection.save() await teamHelper.removeTeamMember(team.id, userId, models.Team) user.teams = user.teams.filter(userTeamId => team.id !== userTeamId) + delete user.passwordResetToken await user.save() return res.status(200).json({}) } catch (e) { diff --git a/packages/component-user-manager/src/routes/collectionsUsers/patch.js b/packages/component-user-manager/src/routes/collectionsUsers/patch.js index 4aedb7f38492f4902acec391aba17894c217942f..fb2521e3320b094ee5cdc9c16cb79d4da951b0d2 100644 --- a/packages/component-user-manager/src/routes/collectionsUsers/patch.js +++ b/packages/component-user-manager/src/routes/collectionsUsers/patch.js @@ -4,7 +4,13 @@ const helpers = require('../../helpers/helpers') module.exports = models => async (req, res) => { // TO DO: add authsome const { collectionId, userId } = req.params - const { isSubmitting, isCorresponding } = req.body + const { + isSubmitting, + isCorresponding, + firstName, + lastName, + affiliation, + } = req.body if (!helpers.checkForUndefinedParams(isSubmitting, isCorresponding)) { res.status(400).json({ error: 'Missing parameters' }) @@ -28,6 +34,9 @@ module.exports = models => async (req, res) => { error: 'Collection and user do not match', }) } + matchingAuthor.firstName = firstName + matchingAuthor.lastName = lastName + matchingAuthor.affiliation = affiliation matchingAuthor.isSubmitting = isSubmitting matchingAuthor.isCorresponding = isCorresponding collection = await collection.save() diff --git a/packages/component-user-manager/src/tests/collectionsUsers/patch.test.js b/packages/component-user-manager/src/tests/collectionsUsers/patch.test.js index e18c21f6f804f59ae7b9f53111fcf7cb56029c67..be165f4b6b4ad890569cf842b582a4e239b02895 100644 --- a/packages/component-user-manager/src/tests/collectionsUsers/patch.test.js +++ b/packages/component-user-manager/src/tests/collectionsUsers/patch.test.js @@ -4,6 +4,8 @@ process.env.SUPPRESS_NO_CONFIG_WARNING = true const httpMocks = require('node-mocks-http') const fixtures = require('./../fixtures/fixtures') const Model = require('./../helpers/Model') +const Chance = require('chance') +const chance = new Chance() const models = Model.build() jest.mock('pubsweet-component-mail-service', () => ({ @@ -17,6 +19,9 @@ const { standardCollection, authorsCollection } = fixtures.collections const body = { isSubmitting: false, isCorresponding: true, + firstName: chance.first(), + lastName: chance.last(), + affiliation: chance.company(), } const patchPath = '../../routes/collectionsUsers/patch' describe('Patch collections users route handler', () => { @@ -36,6 +41,7 @@ describe('Patch collections users route handler', () => { ) expect(matchingAuthor.isSubmitting).toBe(body.isSubmitting) expect(matchingAuthor.isCorresponding).toBe(body.isCorresponding) + expect(matchingAuthor.firstName).toBe(body.firstName) }) it('should return an error when the params are missing', async () => { delete body.isSubmitting