From 99b32cf0595a1a8c0ef309d150c7ee350c5e2c83 Mon Sep 17 00:00:00 2001 From: Alisson Oldoni Date: Wed, 21 Feb 2018 13:47:52 +1100 Subject: [PATCH 1/2] Fix bug Magento 2.2.2 password reset strength meter #13429 by doing the email comparison only if an email field exists --- .../view/frontend/web/js/password-strength-indicator.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Customer/view/frontend/web/js/password-strength-indicator.js b/app/code/Magento/Customer/view/frontend/web/js/password-strength-indicator.js index 71ca63f6750bb..6a180759e7be4 100644 --- a/app/code/Magento/Customer/view/frontend/web/js/password-strength-indicator.js +++ b/app/code/Magento/Customer/view/frontend/web/js/password-strength-indicator.js @@ -31,6 +31,8 @@ define([ this.options.cache.label = $(this.options.passwordStrengthMeterLabelSelector, this.element); // We need to look outside the module for backward compatibility, since someone can already use the module. + // @todo Narrow this selector in 2.3 so it doesn't accidentally finds the the email field from the newsletter + // email field or any other "email" field. this.options.cache.email = $(this.options.formSelector).find(this.options.emailSelector); this._bind(); }, @@ -74,7 +76,9 @@ define([ 'password-not-equal-to-user-name': this.options.cache.email.val() }); - if (password.toLowerCase() === this.options.cache.email.val().toLowerCase()) { + // We should only perform this check in case there is an email field on screen + if (this.options.cache.email.length && + password.toLowerCase() === this.options.cache.email.val().toLowerCase()) { displayScore = 1; } else { isValid = $.validator.validateSingleElement(this.options.cache.input); From fd5e0b5532b56451cadcc03353bae2ff54838fcc Mon Sep 17 00:00:00 2001 From: Alisson Oldoni Date: Wed, 21 Feb 2018 14:22:21 +1100 Subject: [PATCH 2/2] Fixing line 34 length as per jslint configuration --- .../view/frontend/web/js/password-strength-indicator.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Customer/view/frontend/web/js/password-strength-indicator.js b/app/code/Magento/Customer/view/frontend/web/js/password-strength-indicator.js index 6a180759e7be4..be2e0aedfe4bb 100644 --- a/app/code/Magento/Customer/view/frontend/web/js/password-strength-indicator.js +++ b/app/code/Magento/Customer/view/frontend/web/js/password-strength-indicator.js @@ -31,8 +31,8 @@ define([ this.options.cache.label = $(this.options.passwordStrengthMeterLabelSelector, this.element); // We need to look outside the module for backward compatibility, since someone can already use the module. - // @todo Narrow this selector in 2.3 so it doesn't accidentally finds the the email field from the newsletter - // email field or any other "email" field. + // @todo Narrow this selector in 2.3 so it doesn't accidentally finds the the email field from the + // newsletter email field or any other "email" field. this.options.cache.email = $(this.options.formSelector).find(this.options.emailSelector); this._bind(); },