mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
improve confirmation email format
This commit is contained in:
parent
068684d16b
commit
80639311d7
1 changed files with 14 additions and 13 deletions
|
|
@ -93,20 +93,8 @@ 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
|
||||
const sent = 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`,
|
||||
})
|
||||
|
||||
if (!sent) {
|
||||
if (!(await sendConfirmationEmail(user))) {
|
||||
// delete user if email failed to send
|
||||
await AppDataSource.transaction(async (e) => {
|
||||
await setClaims(e, user.id)
|
||||
|
|
@ -149,3 +137,16 @@ const getUser = async (email: string): Promise<User | null> => {
|
|||
relations: ['profile'],
|
||||
})
|
||||
}
|
||||
|
||||
export const sendConfirmationEmail = async (user: User): Promise<boolean> => {
|
||||
// generate confirmation link
|
||||
const confirmationToken = generateVerificationToken(user.id)
|
||||
const confirmationLink = `${env.client.url}/confirm-email/${confirmationToken}`
|
||||
// send email
|
||||
return sendEmail({
|
||||
from: `Omnivore <${env.sender.message}>`,
|
||||
to: user.email,
|
||||
subject: 'Confirm your email',
|
||||
text: `Hey ${user.name},\nPlease confirm your email by clicking the link below:\n\n${confirmationLink}\n\n`,
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue