Total Complexity | 6 |
Total Lines | 52 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
11 | class ResetPasswordForm extends Model |
||
12 | { |
||
13 | public $password; |
||
14 | |||
15 | /** |
||
16 | * @var User |
||
17 | */ |
||
18 | private $_user; |
||
19 | |||
20 | |||
21 | /** |
||
22 | * Creates a form model given a token. |
||
23 | * |
||
24 | * @param string $token |
||
25 | * @param array $config name-value pairs that will be used to initialize the object properties |
||
26 | * @throws InvalidArgumentException if token is empty or not valid |
||
27 | */ |
||
28 | public function __construct($token, $config = []) |
||
29 | { |
||
30 | if (empty($token) || !is_string($token)) { |
||
31 | throw new InvalidArgumentException('Password reset token cannot be blank.'); |
||
32 | } |
||
33 | $this->_user = User::findByPasswordResetToken($token); |
||
34 | if (!$this->_user) { |
||
35 | throw new InvalidArgumentException('Wrong password reset token.'); |
||
36 | } |
||
37 | parent::__construct($config); |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * {@inheritdoc} |
||
42 | */ |
||
43 | public function rules() |
||
48 | ]; |
||
49 | } |
||
50 | |||
51 | /** |
||
52 | * Resets password. |
||
53 | * |
||
54 | * @return bool if password was reset. |
||
55 | */ |
||
56 | public function resetPassword() |
||
63 | } |
||
64 | } |
||
65 |