Commit 80c2c111 authored by Yannis Barlas's avatar Yannis Barlas

fix(api): send verification email to invited users when they sign up

parent 49c36f16
......@@ -240,15 +240,36 @@ const signUp = async (_, { input }, ctx) => {
// If not agreed to tc, user's been invited but is now signing up
delete userInput.email
const updatedUser = await User.query().patchAndFetchById(
existingIdentity.userId,
{
...userInput,
agreedTc: true,
},
)
return updatedUser
try {
let updatedUser, confirmationToken
await transaction(User.knex(), async trx => {
updatedUser = await User.query(trx).patchAndFetchById(
existingIdentity.userId,
{
...userInput,
agreedTc: true,
},
)
confirmationToken = crypto.randomBytes(64).toString('hex')
const confirmationTokenTimestamp = new Date()
await existingIdentity.$query(trx).patch({
confirmationToken,
confirmationTokenTimestamp,
})
})
notify('identityVerification', {
confirmationToken,
email,
})
return updatedUser
} catch (e) {
throw new Error(e)
}
}
if (!existingIdentity) {
......
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