1 | <?php |
||
13 | class PasswordResetBroker implements PasswordResetBrokerContract |
||
|
|||
14 | { |
||
15 | /** |
||
16 | * The application key. |
||
17 | * |
||
18 | * @var string |
||
19 | */ |
||
20 | protected $key; |
||
21 | |||
22 | /** |
||
23 | * The user provider implementation. |
||
24 | * |
||
25 | * @var \Illuminate\Contracts\Auth\UserProvider |
||
26 | */ |
||
27 | protected $users; |
||
28 | |||
29 | /** |
||
30 | * The number of minutes that the reset token should be considered valid. |
||
31 | * |
||
32 | * @var int |
||
33 | */ |
||
34 | protected $expiration; |
||
35 | |||
36 | /** |
||
37 | * Create a new verification broker instance. |
||
38 | * |
||
39 | * @param \Illuminate\Contracts\Auth\UserProvider $users |
||
40 | * @param string $key |
||
41 | * @param int $expiration |
||
42 | */ |
||
43 | public function __construct(UserProvider $users, $key, $expiration) |
||
49 | |||
50 | /** |
||
51 | * Send a password reset link to a user. |
||
52 | * |
||
53 | * @param array $credentials |
||
54 | * |
||
55 | * @return string |
||
56 | */ |
||
57 | public function sendResetLink(array $credentials): string |
||
77 | |||
78 | /** |
||
79 | * Reset the password for the given token. |
||
80 | * |
||
81 | * @param array $credentials |
||
82 | * @param \Closure $callback |
||
83 | * |
||
84 | * @return mixed |
||
85 | */ |
||
86 | public function reset(array $credentials, Closure $callback) |
||
106 | |||
107 | /** |
||
108 | * Get the user for the given credentials. |
||
109 | * |
||
110 | * @param array $credentials |
||
111 | * |
||
112 | * @throws \UnexpectedValueException |
||
113 | * |
||
114 | * @return \Rinvex\Auth\Contracts\CanResetPasswordContract|null |
||
115 | */ |
||
116 | public function getUser(array $credentials): ?CanResetPasswordContract |
||
126 | |||
127 | /** |
||
128 | * Create a new password reset token for the given user. |
||
129 | * |
||
130 | * @param \Rinvex\Auth\Contracts\CanResetPasswordContract $user |
||
131 | * @param int $expiration |
||
132 | * |
||
133 | * @return string |
||
134 | */ |
||
135 | public function createToken(CanResetPasswordContract $user, $expiration): string |
||
141 | |||
142 | /** |
||
143 | * Validate the given password reset token. |
||
144 | * |
||
145 | * @param \Rinvex\Auth\Contracts\CanResetPasswordContract $user |
||
146 | * @param array $credentials |
||
147 | * |
||
148 | * @return bool |
||
149 | */ |
||
150 | public function validateToken(CanResetPasswordContract $user, array $credentials): bool |
||
156 | |||
157 | /** |
||
158 | * Validate the given expiration timestamp. |
||
159 | * |
||
160 | * @param int $expiration |
||
161 | * |
||
162 | * @return bool |
||
163 | */ |
||
164 | public function validateTimestamp($expiration): bool |
||
168 | |||
169 | /** |
||
170 | * Return the application key. |
||
171 | * |
||
172 | * @return string |
||
173 | */ |
||
174 | public function getKey(): string |
||
182 | |||
183 | /** |
||
184 | * Returns the payload string containing. |
||
185 | * |
||
186 | * @param \Rinvex\Auth\Contracts\CanResetPasswordContract $user |
||
187 | * @param string $email |
||
188 | * @param int $expiration |
||
189 | * |
||
190 | * @return string |
||
191 | */ |
||
192 | protected function buildPayload(CanResetPasswordContract $user, $email, $expiration): string |
||
201 | |||
202 | /** |
||
203 | * Validate a password reset for the given credentials. |
||
204 | * |
||
205 | * @param array $credentials |
||
206 | * |
||
207 | * @return \Illuminate\Contracts\Auth\CanResetPassword|string |
||
208 | */ |
||
209 | protected function validateReset(array $credentials) |
||
225 | } |
||
226 |