Skip to content

Commit

Permalink
fix: Username is undefined in email verification link on email chan…
Browse files Browse the repository at this point in the history
…ge (#8887)
  • Loading branch information
mtrezza authored Jan 14, 2024
1 parent 3c07fca commit e315c13
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions spec/ValidationAndPasswordsReset.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ describe('Custom Pages, Email Verification, Password Reset', () => {
spyOn(emailAdapter, 'sendVerificationEmail').and.callFake(options => {
expect(options.link).not.toBeNull();
expect(options.link).not.toMatch(/token=undefined/);
expect(options.link).not.toMatch(/username=undefined/);
Promise.resolve();
});
const user = new Parse.User();
Expand Down
5 changes: 3 additions & 2 deletions src/Controllers/UserController.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ export class UserController extends AdaptableController {
return;
}
const token = encodeURIComponent(user._email_verify_token);
// We may need to fetch the user in case of update email
// We may need to fetch the user in case of update email; only use the `fetchedUser`
// from this point onwards; do not use the `user` as it may not contain all fields.
const fetchedUser = await this.getUserIfNeeded(user);
let shouldSendEmail = this.config.sendUserEmailVerification;
if (typeof shouldSendEmail === 'function') {
Expand All @@ -176,7 +177,7 @@ export class UserController extends AdaptableController {
if (!shouldSendEmail) {
return;
}
const username = encodeURIComponent(user.username);
const username = encodeURIComponent(fetchedUser.username);

const link = buildEmailLink(this.config.verifyEmailURL, username, token, this.config);
const options = {
Expand Down

0 comments on commit e315c13

Please sign in to comment.