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