Skip to content

Commit

Permalink
Add parseFrameURL for masking user-facing pages.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
lenart committed Nov 21, 2016
1 parent edb7b70 commit f24cc28
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,10 @@ export class Config {
return this.customPages.passwordResetSuccess || `${this.publicServerURL}/apps/password_reset_success.html`;
}

get parseFrameURL() {
return this.customPages.parseFrameURL || null;
}

get verifyEmailURL() {
return `${this.publicServerURL}/apps/${this.applicationId}/verify_email`;
}
Expand Down
15 changes: 13 additions & 2 deletions src/Controllers/UserController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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;

0 comments on commit f24cc28

Please sign in to comment.