From 9abf17730f37466a35d446a1712d7cd0b9e86249 Mon Sep 17 00:00:00 2001 From: Halim Qarroum Date: Thu, 10 Nov 2016 18:40:17 +0100 Subject: [PATCH] Injected the username when password has changed. (#3033) * Injected the username when password has changed. When the resetPassword controller has successfully updated the user's password, it now redirects the user to the password changed page with the username as a query parameters. * Update unit test for password_reset_success redirect --- spec/ValidationAndPasswordsReset.spec.js | 2 +- src/Routers/PublicAPIRouter.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/spec/ValidationAndPasswordsReset.spec.js b/spec/ValidationAndPasswordsReset.spec.js index 62ed514e..04dad59d 100644 --- a/spec/ValidationAndPasswordsReset.spec.js +++ b/spec/ValidationAndPasswordsReset.spec.js @@ -816,7 +816,7 @@ describe("Custom Pages, Email Verification, Password Reset", () => { return; } expect(response.statusCode).toEqual(302); - expect(response.body).toEqual('Found. Redirecting to http://localhost:8378/1/apps/password_reset_success.html'); + expect(response.body).toEqual('Found. Redirecting to http://localhost:8378/1/apps/password_reset_success.html?username=zxcv'); Parse.User.logIn("zxcv", "hello").then(function(user){ let config = new Config('test'); diff --git a/src/Routers/PublicAPIRouter.js b/src/Routers/PublicAPIRouter.js index 31e11035..efad9087 100644 --- a/src/Routers/PublicAPIRouter.js +++ b/src/Routers/PublicAPIRouter.js @@ -102,9 +102,10 @@ export class PublicAPIRouter extends PromiseRouter { } return config.userController.updatePassword(username, token, new_password).then((result) => { + let params = qs.stringify({username: username}); return Promise.resolve({ status: 302, - location: config.passwordResetSuccessURL + location: `${config.passwordResetSuccessURL}?${params}` }); }, (err) => { let params = qs.stringify({username: username, token: token, id: config.applicationId, error:err, app:config.appName})