File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed
app/code/Magento/Customer/view/frontend/web/js Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,11 @@ define([
3131 this . options . cache . input = $ ( this . options . passwordSelector , this . element ) ;
3232 this . options . cache . meter = $ ( this . options . passwordStrengthMeterSelector , this . element ) ;
3333 this . options . cache . label = $ ( this . options . passwordStrengthMeterLabelSelector , this . element ) ;
34+
35+ // We need to look outside the module for backward compatibility, since someone can already use the module.
36+ // @todo Narrow this selector in 2.3 so it doesn't accidentally finds the the email field from the
37+ // newsletter email field or any other "email" field.
38+ this . options . cache . email = $ ( this . options . formSelector ) . find ( this . options . emailSelector ) ;
3439 this . _bind ( ) ;
3540 } ,
3641
@@ -60,8 +65,20 @@ define([
6065 // Display score is based on combination of whether password is empty, valid, and zxcvbn strength
6166 if ( isEmpty ) {
6267 displayScore = 0 ;
63- } else if ( ! isValid ) {
64- displayScore = 1 ;
68+ } else {
69+ this . options . cache . input . rules ( 'add' , {
70+ 'password-not-equal-to-user-name' : this . options . cache . email . val ( )
71+ } ) ;
72+
73+ // We should only perform this check in case there is an email field on screen
74+ if ( this . options . cache . email . length &&
75+ password . toLowerCase ( ) === this . options . cache . email . val ( ) . toLowerCase ( ) ) {
76+ displayScore = 1 ;
77+ } else {
78+ isValid = $ . validator . validateSingleElement ( this . options . cache . input ) ;
79+ zxcvbnScore = zxcvbn ( password ) . score ;
80+ displayScore = isValid ? zxcvbnScore : 1 ;
81+ }
6582 }
6683
6784 // Update label
You can’t perform that action at this time.
0 commit comments