Commit 5f20a06c authored by Tania Fecheta's avatar Tania Fecheta

Merge branch 'HIN-1253-decline-reviewer-invitation-from-email' into 'develop'

fix(fragmentInvitations/post): add invitation token to a user when he is invited…

See merge request !229
parents 2cad69ca 08b4b632
......@@ -7,6 +7,9 @@ const {
Fragment,
authsome: authsomeHelper,
} = require('pubsweet-component-helper-service')
const Chance = require('chance')
const chance = new Chance()
const emailInvitations = require('./emails/invitations')
......@@ -75,6 +78,10 @@ module.exports = models => async (req, res) => {
try {
const user = await UserModel.findByEmail(email)
if (user.accessTokens && !user.accessTokens.invitation) {
user.accessTokens.invitation = chance.hash()
await user.save()
}
const canInvite = await authsome.can(req.user, '', {
targetUser: user,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment