Total Complexity | 7 |
Total Lines | 68 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
16 | class PasswordResetRequestForm extends Model |
||
17 | { |
||
18 | public $email; |
||
19 | |||
20 | /** |
||
21 | * @inheritdoc |
||
22 | * @return array |
||
23 | */ |
||
24 | public function rules() |
||
34 | ], |
||
35 | ]; |
||
36 | } |
||
37 | |||
38 | /** |
||
39 | * Sends an email with a link, for resetting the password. |
||
40 | * |
||
41 | * @return bool whether the email was send |
||
42 | */ |
||
43 | public function sendEmail() |
||
44 | { |
||
45 | |||
46 | if ($user = $this->getUser()) { |
||
47 | return Yii::$app->mailer->compose( |
||
48 | [ |
||
49 | 'html' => '@modules/users/mail/passwordResetToken-html', |
||
50 | 'text' => '@modules/users/mail/passwordResetToken-text' |
||
51 | ], |
||
52 | ['user' => $user] |
||
53 | ) |
||
54 | ->setFrom([Yii::$app->params['supportEmail'] => Yii::$app->name . ' robot']) |
||
55 | ->setTo($this->email) |
||
56 | ->setSubject(Yii::$app->name . ' | ' . Module::t('module', 'Access recovery')) |
||
57 | ->send(); |
||
58 | } |
||
59 | return false; |
||
60 | } |
||
61 | |||
62 | /** |
||
63 | * @return bool|User |
||
64 | */ |
||
65 | private function getUser() |
||
84 | } |
||
85 | } |
||
86 |