Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7e19c9d

Browse files
committed
Work on reminder system.
1 parent b9a8aac commit 7e19c9d

2 files changed

Lines changed: 73 additions & 2 deletions

File tree

src/Illuminate/Auth/Reminders/PasswordBroker.php

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

src/Illuminate/Support/Facades/Password.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,41 @@
22

33
class Password extends Facade {
44

5+
/**
6+
* Constant representing a successfully sent reminder.
7+
*
8+
* @var int
9+
*/
10+
const REMINDER_SENT = 1;
11+
12+
/**
13+
* Constant representing a successfully reset password.
14+
*
15+
* @var int
16+
*/
17+
const PASSWORD_RESET = 2;
18+
19+
/**
20+
* Constant representing the user not found response.
21+
*
22+
* @var int
23+
*/
24+
const INVALID_USER = 3;
25+
26+
/**
27+
* Constant representing an invalid password.
28+
*
29+
* @var int
30+
*/
31+
const INVALID_PASSWORD = 4;
32+
33+
/**
34+
* Constant representing an invalid token.
35+
*
36+
* @var int
37+
*/
38+
const INVALID_TOKEN = 5;
39+
540
/**
641
* Get the registered name of the component.
742
*

0 commit comments

Comments
 (0)