@@ -23,6 +23,66 @@ public function __construct(
23
23
$ this ->eventManager = $ eventManager ;
24
24
}
25
25
26
+ /**
27
+ * @param string|null $password
28
+ */
29
+ private function dispatchPasswordCheckEvent ($ password )
30
+ {
31
+ if (!is_null ($ password )) {
32
+ $ this ->eventManager ->dispatch (
33
+ 'timpack_pwnedvalidator_check_password_strength ' ,
34
+ [
35
+ 'password ' => $ password ,
36
+ ]
37
+ );
38
+ }
39
+ }
40
+
41
+ /**
42
+ * @param AccountManagementInterface $subject
43
+ * @param string $email
44
+ * @param string $resetToken
45
+ * @param string $newPassword
46
+ */
47
+ public function beforeResetPassword (
48
+ AccountManagementInterface $ subject ,
49
+ $ email ,
50
+ $ resetToken ,
51
+ $ newPassword
52
+ ) {
53
+ $ this ->dispatchPasswordCheckEvent ($ newPassword );
54
+ }
55
+
56
+ /**
57
+ * @param AccountManagementInterface $subject
58
+ * @param string $email
59
+ * @param string $currentPassword
60
+ * @param string $newPassword
61
+ */
62
+ public function beforeChangePassword (
63
+ AccountManagementInterface $ subject ,
64
+ $ email ,
65
+ $ currentPassword ,
66
+ $ newPassword
67
+ ) {
68
+ $ this ->dispatchPasswordCheckEvent ($ newPassword );
69
+ }
70
+
71
+ /**
72
+ * @param AccountManagementInterface $subject
73
+ * @param string $customerId
74
+ * @param string $currentPassword
75
+ * @param string $newPassword
76
+ */
77
+ public function beforeChangePasswordById (
78
+ AccountManagementInterface $ subject ,
79
+ $ customerId ,
80
+ $ currentPassword ,
81
+ $ newPassword
82
+ ) {
83
+ $ this ->dispatchPasswordCheckEvent ($ newPassword );
84
+ }
85
+
26
86
/**
27
87
* @param AccountManagementInterface $subject
28
88
* @param CustomerInterface $customer
@@ -35,13 +95,6 @@ public function beforeCreateAccount(
35
95
$ password = null ,
36
96
$ redirectUrl = ''
37
97
) {
38
- if (!is_null ($ password )) {
39
- $ this ->eventManager ->dispatch (
40
- 'timpack_pwnedvalidator_check_password_strength ' ,
41
- [
42
- 'password ' => $ password ,
43
- ]
44
- );
45
- }
98
+ $ this ->dispatchPasswordCheckEvent ($ password );
46
99
}
47
100
}
0 commit comments