File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -64,6 +64,28 @@ protected function tryChangePassword(
64
64
$ model ->error = "PASSWORD_INCORRECT " ;
65
65
return ;
66
66
}
67
+ $ pwlen = strlen ($ pw2 );
68
+ $ req = &Common::$ config ->bnetdocs ->user_register_requirements ;
69
+ $ email = Authentication::$ user ->getEmail ();
70
+ $ username = Authentication::$ user ->getUsername ();
71
+ if (!$ req ->password_allow_email && stripos ($ pw2 , $ email )) {
72
+ $ model ->error = "PASSWORD_CONTAINS_EMAIL " ;
73
+ return ;
74
+ }
75
+ if (!$ req ->password_allow_username && stripos ($ pw2 , $ username )) {
76
+ $ model ->error = "PASSWORD_CONTAINS_USERNAME " ;
77
+ return ;
78
+ }
79
+ if (is_numeric ($ req ->password_length_max )
80
+ && $ pwlen > $ req ->password_length_max ) {
81
+ $ model ->error = "PASSWORD_TOO_LONG " ;
82
+ return ;
83
+ }
84
+ if (is_numeric ($ req ->password_length_min )
85
+ && $ pwlen < $ req ->password_length_min ) {
86
+ $ model ->error = "PASSWORD_TOO_SHORT " ;
87
+ return ;
88
+ }
67
89
$ blacklist = Common::$ config ->bnetdocs ->user_password_blacklist ;
68
90
foreach ($ blacklist as $ blacklist_pw ) {
69
91
if (strtolower ($ blacklist_pw ->password ) == strtolower ($ pw2 )) {
Original file line number Diff line number Diff line change @@ -20,9 +20,22 @@ switch ($this->getContext()->error) {
20
20
case "NONMATCHING_PASSWORD " :
21
21
$ message = "The new password does not match its confirmation. " ;
22
22
break ;
23
+ case "PASSWORD_CONTAINS_EMAIL " :
24
+ $ message = "The password contains the email address, "
25
+ . "use a better password. " ;
26
+ break ;
27
+ case "PASSWORD_CONTAINS_USERNAME " :
28
+ $ message = "The password contains the username, use a better password. " ;
29
+ break ;
23
30
case "PASSWORD_INCORRECT " :
24
31
$ message = "You did not enter your correct current password. " ;
25
32
break ;
33
+ case "PASSWORD_TOO_LONG " :
34
+ $ message = "The password is too long, shorten it. " ;
35
+ break ;
36
+ case "PASSWORD_TOO_SHORT " :
37
+ $ message = "The password is too short, use a better password. " ;
38
+ break ;
26
39
case "PASSWORD_BLACKLIST " :
27
40
$ message = $ this ->getContext ()->error_extra ;
28
41
if (empty ($ message )) $ message = "The new password is blacklisted. " ;
You can’t perform that action at this time.
0 commit comments