@@ -69,6 +69,13 @@ class PasswordBroker {
6969 */
7070 protected $ reminderView ;
7171
72+ /**
73+ * The custom password validator callback.
74+ *
75+ * @var \Closure
76+ */
77+ protected $ passwordValidator ;
78+
7279 /**
7380 * Create a new password broker instance.
7481 *
@@ -105,7 +112,7 @@ public function remind(array $credentials, Closure $callback = null)
105112
106113 if (is_null ($ user ))
107114 {
108- return self ::USER_NOT_FOUND ;
115+ return self ::INVALID_USER ;
109116 }
110117
111118 // Once we have the reminder token, we are ready to send a message out to the
@@ -182,7 +189,7 @@ protected function validateReset(array $credentials)
182189 {
183190 if (is_null ($ user = $ this ->getUser ($ credentials )))
184191 {
185- return self ::USER_NOT_FOUND ;
192+ return self ::INVALID_USER ;
186193 }
187194
188195 if ( ! $ this ->validNewPasswords ($ credentials ))
@@ -198,13 +205,42 @@ protected function validateReset(array $credentials)
198205 return $ user ;
199206 }
200207
208+ /**
209+ * Set a custom password validator.
210+ *
211+ * @param \Closure $callback
212+ * @return void
213+ */
214+ public function validator (Closure $ callback )
215+ {
216+ $ this ->passwordValidator = $ callback ;
217+ }
218+
201219 /**
202220 * Determine if the passwords match for the request.
203221 *
204222 * @param array $credentials
205223 * @return bool
206224 */
207225 protected function validNewPasswords (array $ credentials )
226+ {
227+ if (isset ($ this ->passwordValidator ))
228+ {
229+ return call_user_func ($ this ->passwordValidator , $ credentials );
230+ }
231+ else
232+ {
233+ return $ this ->validatePasswordWithDefaults ($ credentials );
234+ }
235+ }
236+
237+ /**
238+ * Determine if the passwords are valid for the request.
239+ *
240+ * @param array $credentials
241+ * @return bool
242+ */
243+ protected function validatePasswordWithDefaults (array $ credentials )
208244 {
209245 list ($ password , $ confirm ) = array ($ credentials ['password ' ], $ credentials ['password_confirmation ' ]);
210246
0 commit comments