Add parseFrameURL for masking user-facing pages (#3267)
* Add parseFrameURL for masking user-facing pages. Allow users to specify a different address which is used to mask parse requests for verifying email and resetting password. This is how Parse.com used to allow customers to gain control over page content, styling etc. On the destination page javascript is used to check the link in the request and embed the parse server page using IFRAME. * Fix code indentation * Rename method for building link and pass config to it. * Add customPages options to README.md. * Add tests for parseFrameURL email link building, and parseFrameURL option. * Add parseFrameURL for masking user-facing pages. Allow users to specify a different address which is used to mask parse requests for verifying email and resetting password. This is how Parse.com used to allow customers to gain control over page content, styling etc. On the destination page javascript is used to check the link in the request and embed the parse server page using IFRAME. * Fix code indentation * Rename method for building link and pass config to it. * Add customPages options to README.md. * Don't Object.assign to defaultConfiguration global
This commit is contained in:
committed by
Arthur Cinader
parent
f331f6644c
commit
5d9dbea07b
@@ -119,7 +119,8 @@ 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);
|
||||
const link = `${this.config.verifyEmailURL}?token=${token}&username=${username}`;
|
||||
|
||||
const link = buildEmailLink(this.config.verifyEmailURL, username, token, this.config);
|
||||
const options = {
|
||||
appName: this.config.appName,
|
||||
link: link,
|
||||
@@ -153,8 +154,8 @@ export class UserController extends AdaptableController {
|
||||
.then(user => {
|
||||
const token = encodeURIComponent(user._perishable_token);
|
||||
const username = encodeURIComponent(user.username);
|
||||
const link = `${this.config.requestResetPasswordURL}?token=${token}&username=${username}`
|
||||
|
||||
const link = buildEmailLink(this.config.requestResetPasswordURL, username, token, this.config);
|
||||
const options = {
|
||||
appName: this.config.appName,
|
||||
link: link,
|
||||
@@ -215,4 +216,16 @@ function updateUserPassword(userId, password, config) {
|
||||
});
|
||||
}
|
||||
|
||||
function buildEmailLink(destination, username, token, config) {
|
||||
const usernameAndToken = `token=${token}&username=${username}`
|
||||
|
||||
if (config.parseFrameURL) {
|
||||
const destinationWithoutHost = destination.replace(config.publicServerURL, '');
|
||||
|
||||
return `${config.parseFrameURL}?link=${encodeURIComponent(destinationWithoutHost)}&${usernameAndToken}`;
|
||||
} else {
|
||||
return `${destination}?${usernameAndToken}`;
|
||||
}
|
||||
}
|
||||
|
||||
export default UserController;
|
||||
|
||||
Reference in New Issue
Block a user