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