Conditions | 4 |
Paths | 4 |
Total Lines | 27 |
Code Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
38 | public function sendEmail() |
||
39 | { |
||
40 | /* @var $user \modules\users\models\User */ |
||
41 | $user = User::findOne([ |
||
42 | 'status' => User::STATUS_ACTIVE, |
||
43 | 'email' => $this->email, |
||
44 | ]); |
||
45 | |||
46 | if (!$user) { |
||
47 | return false; |
||
48 | } |
||
49 | |||
50 | if (!User::isPasswordResetTokenValid($user->password_reset_token)) { |
||
51 | $user->generatePasswordResetToken(); |
||
52 | if (!$user->save()) { |
||
53 | return false; |
||
54 | } |
||
55 | } |
||
56 | |||
57 | return Yii::$app->mailer->compose( |
||
58 | ['html' => '@modules/users/mail/passwordResetToken-html', 'text' => '@modules/users/mail/passwordResetToken-text'], |
||
59 | ['user' => $user]) |
||
60 | ->setFrom([Yii::$app->params['supportEmail'] => Yii::$app->name . ' robot']) |
||
61 | ->setTo($this->email) |
||
62 | ->setSubject(Module::t('module', 'Password reset for') . ' ' . Yii::$app->name) |
||
63 | ->send(); |
||
64 | } |
||
65 | } |
||
66 |