From d64c411afb63616c0decf004bad9bf4b7119a00c Mon Sep 17 00:00:00 2001 From: Manuel Trezza <5673677+mtrezza@users.noreply.github.com> Date: Sat, 13 Apr 2024 20:51:42 +0200 Subject: [PATCH 1/2] refactor --- src/ParseUser.js | 7 ++++++- src/RESTController.js | 4 ---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/ParseUser.js b/src/ParseUser.js index 9347d1239..74673540e 100644 --- a/src/ParseUser.js +++ b/src/ParseUser.js @@ -1262,7 +1262,12 @@ const DefaultController = { verifyPassword(username: string, password: string, options: RequestOptions) { const RESTController = CoreManager.getRESTController(); - return RESTController.request('GET', 'verifyPassword', { username, password }, options); + const data = { + username, + password, + ...(options.ignoreEmailVerification !== undefined && { ignoreEmailVerification: options.ignoreEmailVerification }), + }; + return RESTController.request('GET', 'verifyPassword', data, options); }, requestEmailVerification(email: string, options: RequestOptions) { diff --git a/src/RESTController.js b/src/RESTController.js index 73c962cff..552c3d058 100644 --- a/src/RESTController.js +++ b/src/RESTController.js @@ -250,10 +250,6 @@ const RESTController = { } } - if (options.ignoreEmailVerification !== undefined) { - payload.ignoreEmailVerification = options.ignoreEmailVerification; - } - if (CoreManager.get('FORCE_REVOCABLE_SESSION')) { payload._RevocableSession = '1'; } From 37ef74af6ec5cb641517d41ae3d223c9ea6a91b3 Mon Sep 17 00:00:00 2001 From: Manuel Trezza <5673677+mtrezza@users.noreply.github.com> Date: Sat, 13 Apr 2024 21:06:48 +0200 Subject: [PATCH 2/2] add docs --- src/ParseUser.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/ParseUser.js b/src/ParseUser.js index 74673540e..26dec8820 100644 --- a/src/ParseUser.js +++ b/src/ParseUser.js @@ -546,10 +546,11 @@ class ParseUser extends ParseObject { /** * Verify whether a given password is the password of the current user. * - * @param {string} password A password to be verified - * @param {object} options - * @returns {Promise} A promise that is fulfilled with a user - * when the password is correct. + * @param {string} password The password to be verified. + * @param {object} options The options. + * @param {boolean} [options.ignoreEmailVerification=false] Set to `true` to bypass email verification and verify + * the password regardless of whether the email has been verified. This requires the master key. + * @returns {Promise} A promise that is fulfilled with a user when the password is correct. */ verifyPassword(password: string, options?: RequestOptions): Promise { const username = this.getUsername() || ''; @@ -865,13 +866,14 @@ class ParseUser extends ParseObject { /** * Verify whether a given password is the password of the current user. - * - * @param {string} username A username to be used for identificaiton - * @param {string} password A password to be verified - * @param {object} options * @static - * @returns {Promise} A promise that is fulfilled with a user - * when the password is correct. + * + * @param {string} username The username of the user whose password should be verified. + * @param {string} password The password to be verified. + * @param {object} options The options. + * @param {boolean} [options.ignoreEmailVerification=false] Set to `true` to bypass email verification and verify + * the password regardless of whether the email has been verified. This requires the master key. + * @returns {Promise} A promise that is fulfilled with a user when the password is correct. */ static verifyPassword(username: string, password: string, options?: RequestOptions) { if (typeof username !== 'string') {