send confirmation email to pending user
This commit is contained in:
committed by
Jackson Harper
parent
7293469468
commit
1ea34bde62
@ -9,6 +9,9 @@ import { Invite } from '../entity/groups/invite'
|
||||
import { GroupMembership } from '../entity/groups/group_membership'
|
||||
import { AppDataSource } from '../server'
|
||||
import { getRepository } from '../entity/utils'
|
||||
import { generateVerificationToken } from '../utils/auth'
|
||||
import { env } from '../env'
|
||||
import { sendEmail } from '../utils/sendEmail'
|
||||
|
||||
export const createUser = async (input: {
|
||||
provider: AuthProvider
|
||||
@ -90,6 +93,20 @@ export const createUser = async (input: {
|
||||
}
|
||||
)
|
||||
|
||||
// send confirmation email
|
||||
if (input.pendingConfirmation) {
|
||||
// generate confirmation link
|
||||
const confirmationToken = generateVerificationToken(user.id)
|
||||
const confirmationLink = `${env.client.url}/confirm-email/${confirmationToken}`
|
||||
// send email
|
||||
await sendEmail({
|
||||
from: env.sender.message,
|
||||
to: user.email,
|
||||
subject: 'Confirm your email',
|
||||
text: `Please confirm your email by clicking the link below:\n\n${confirmationLink}\n\n`,
|
||||
})
|
||||
}
|
||||
|
||||
return [user, profile]
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user