ensures token is delivered properly within verification email

This commit is contained in:
James
2020-11-08 14:48:56 -05:00
parent f4c066e475
commit b11aa62001
3 changed files with 116 additions and 101 deletions

View File

@@ -1,4 +1,4 @@
function sendVerificationEmail(args) {
async function sendVerificationEmail(args) {
// Verify token from e-mail
const {
config,
@@ -9,10 +9,11 @@ function sendVerificationEmail(args) {
user,
disableEmail,
req,
token,
} = args;
if (!disableEmail) {
const defaultVerificationURL = `${config.serverURL}${config.routes.admin}/${collectionConfig.slug}/verify/${user._verificationToken}`;
const defaultVerificationURL = `${config.serverURL}${config.routes.admin}/${collectionConfig.slug}/verify/${token}`;
let html = `A new account has just been created for you to access <a href="${config.serverURL}">${config.serverURL}</a>.
Please click on the following link or paste the URL below into your browser to verify your email:
@@ -21,9 +22,9 @@ function sendVerificationEmail(args) {
// Allow config to override email content
if (typeof collectionConfig.auth.verify.generateEmailHTML === 'function') {
html = collectionConfig.auth.verify.generateEmailHTML({
html = await collectionConfig.auth.verify.generateEmailHTML({
req,
token: user._verificationToken,
token,
user,
});
}
@@ -32,9 +33,9 @@ function sendVerificationEmail(args) {
// Allow config to override email subject
if (typeof collectionConfig.auth.verify.generateEmailSubject === 'function') {
subject = collectionConfig.auth.verify.generateEmailSubject({
subject = await collectionConfig.auth.verify.generateEmailSubject({
req,
token: user._verificationToken,
token,
email: user.email,
});
}

View File

@@ -215,6 +215,7 @@ async function create(args) {
sendEmail: this.sendEmail,
collection: { config: collectionConfig, Model },
user: result,
token: data._verificationToken,
req,
});
}