Skip to content

Commit ec61bd4

Browse files
committed
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.
1 parent edb7b70 commit ec61bd4

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/Config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,10 @@ export class Config {
236236
return this.customPages.passwordResetSuccess || `${this.publicServerURL}/apps/password_reset_success.html`;
237237
}
238238

239+
get parseFrameURL() {
240+
return this.customPages.parseFrameURL;
241+
}
242+
239243
get verifyEmailURL() {
240244
return `${this.publicServerURL}/apps/${this.applicationId}/verify_email`;
241245
}

src/Controllers/UserController.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ export class UserController extends AdaptableController {
120120
// We may need to fetch the user in case of update email
121121
this.getUserIfNeeded(user).then((user) => {
122122
const username = encodeURIComponent(user.username);
123-
let link = `${this.config.verifyEmailURL}?token=${token}&username=${username}`;
123+
let link = buildVerificationLink(this.config.verifyEmailURL, username, token);
124124
let options = {
125125
appName: this.config.appName,
126126
link: link,
@@ -155,8 +155,8 @@ export class UserController extends AdaptableController {
155155
.then(user => {
156156
const token = encodeURIComponent(user._perishable_token);
157157
const username = encodeURIComponent(user.username);
158-
let link = `${this.config.requestResetPasswordURL}?token=${token}&username=${username}`
159158

159+
let link = buildVerificationLink(this.config.requestResetPasswordURL, username, token);
160160
let options = {
161161
appName: this.config.appName,
162162
link: link,
@@ -217,4 +217,15 @@ function updateUserPassword(userId, password, config) {
217217
});
218218
}
219219

220+
function buildVerificationLink(destination, username, token) {
221+
let usernameAndToken = `token=${token}&username=${username}`
222+
223+
if (this.config.parseFrameURL) {
224+
let destinationWithoutHost = destination.replace(this.config.publicServerURL, '');
225+
return `${this.config.parseFrameURL}?link=${encodeURIComponent(destinationWithoutHost)}&${usernameAndToken}`;
226+
} else {
227+
return `${this.config.requestResetPasswordURL}?${usernameAndToken}`;
228+
}
229+
}
230+
220231
export default UserController;

0 commit comments

Comments
 (0)