From ecafdf124aaa013446fe08130a9c191f25064233 Mon Sep 17 00:00:00 2001 From: Manuel Trezza <5673677+mtrezza@users.noreply.github.com> Date: Mon, 15 Jan 2024 00:26:32 +0100 Subject: [PATCH 1/2] fix --- src/Controllers/UserController.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Controllers/UserController.js b/src/Controllers/UserController.js index d2dcbcd1df..ba72b476a1 100644 --- a/src/Controllers/UserController.js +++ b/src/Controllers/UserController.js @@ -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') { @@ -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 = { From 0ee4df0feb6e38967064dcfb656c3dad298304a3 Mon Sep 17 00:00:00 2001 From: Manuel Trezza <5673677+mtrezza@users.noreply.github.com> Date: Mon, 15 Jan 2024 00:31:45 +0100 Subject: [PATCH 2/2] fix test --- spec/ValidationAndPasswordsReset.spec.js | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/ValidationAndPasswordsReset.spec.js b/spec/ValidationAndPasswordsReset.spec.js index 5b450c1e68..0845abeda1 100644 --- a/spec/ValidationAndPasswordsReset.spec.js +++ b/spec/ValidationAndPasswordsReset.spec.js @@ -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();