fix: wrong links in verification and forgot password emails if serverURL not set (#3010)

This commit is contained in:
Alessio Gravili
2023-08-04 17:30:09 +02:00
committed by GitHub
parent 8c4d2514b0
commit 6a189c6548
2 changed files with 7 additions and 3 deletions

View File

@@ -85,9 +85,11 @@ async function forgotPassword(incomingArgs: Arguments): Promise<string | null> {
const userJSON = user.toJSON({ virtuals: true });
if (!disableEmail) {
const serverURL = (config.serverURL !== null && config.serverURL !== '') ? config.serverURL : `${req.protocol}://${req.get('host')}`;
let html = `${t('authentication:youAreReceivingResetPassword')}
<a href="${config.serverURL}${config.routes.admin}/reset/${token}">
${config.serverURL}${config.routes.admin}/reset/${token}
<a href="${serverURL}${config.routes.admin}/reset/${token}">
${serverURL}${config.routes.admin}/reset/${token}
</a>
${t('authentication:youDidNotRequestPassword')}`;

View File

@@ -32,7 +32,9 @@ async function sendVerificationEmail(args: Args): Promise<void> {
} = args;
if (!disableEmail) {
const verificationURL = `${config.serverURL}${config.routes.admin}/${collectionConfig.slug}/verify/${token}`;
const serverURL = (config.serverURL !== null && config.serverURL !== '') ? config.serverURL : `${req.protocol}://${req.get('host')}`;
const verificationURL = `${serverURL}${config.routes.admin}/${collectionConfig.slug}/verify/${token}`;
let html = `${req.t('authentication:newAccountCreated', { interpolation: { escapeValue: false }, serverURL: config.serverURL, verificationURL })}`;