diff --git a/src/Config.js b/src/Config.js index d2fa2726e93..7406baeef11 100644 --- a/src/Config.js +++ b/src/Config.js @@ -236,6 +236,10 @@ export class Config { return this.customPages.passwordResetSuccess || `${this.publicServerURL}/apps/password_reset_success.html`; } + get parseFrameURL() { + return this.customPages.parseFrameURL; + } + get verifyEmailURL() { return `${this.publicServerURL}/apps/${this.applicationId}/verify_email`; } diff --git a/src/Controllers/UserController.js b/src/Controllers/UserController.js index d54f036b458..595e63e67ef 100644 --- a/src/Controllers/UserController.js +++ b/src/Controllers/UserController.js @@ -120,7 +120,7 @@ export class UserController extends AdaptableController { // We may need to fetch the user in case of update email this.getUserIfNeeded(user).then((user) => { const username = encodeURIComponent(user.username); - let link = `${this.config.verifyEmailURL}?token=${token}&username=${username}`; + let link = buildVerificationLink(this.config.verifyEmailURL, username, token); let options = { appName: this.config.appName, link: link, @@ -155,8 +155,8 @@ export class UserController extends AdaptableController { .then(user => { const token = encodeURIComponent(user._perishable_token); const username = encodeURIComponent(user.username); - let link = `${this.config.requestResetPasswordURL}?token=${token}&username=${username}` + let link = buildVerificationLink(this.config.requestResetPasswordURL, username, token); let options = { appName: this.config.appName, link: link, @@ -217,4 +217,15 @@ function updateUserPassword(userId, password, config) { }); } +function buildVerificationLink(destination, username, token) { + let usernameAndToken = `token=${token}&username=${username}` + + if (this.config.parseFrameURL) { + let destinationWithoutHost = destination.replace(this.config.publicServerURL, ''); + return `${this.config.parseFrameURL}?link=${encodeURIComponent(destinationWithoutHost)}&${usernameAndToken}`; + } else { + return `${this.config.requestResetPasswordURL}?${usernameAndToken}`; + } + } + export default UserController;