| Conditions | 3 |
| Paths | 4 |
| Total Lines | 24 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 44 | public function sendEmail(User $user): void |
||
| 45 | { |
||
| 46 | $tokenizer = new Tokenizer(); |
||
| 47 | if (!$tokenizer->validate($user->email_confirm_token)) { |
||
| 48 | $user->setEmailConfirmToken($tokenizer->generate()); |
||
| 49 | $user->updateAttributes([ |
||
| 50 | 'email_confirm_token' => $user->email_confirm_token, |
||
| 51 | 'date_confirm' => $user->date_confirm, |
||
| 52 | ]); |
||
| 53 | } |
||
| 54 | |||
| 55 | $sent = Yii::$app->notify->sendMessage( |
||
| 56 | $user->email, |
||
| 57 | Yii::t('app', 'Activate Your Account'), |
||
| 58 | 'emailConfirmToken', |
||
| 59 | ['user' => $user] |
||
| 60 | ); |
||
| 61 | |||
| 62 | if (!$sent) { |
||
| 63 | throw new UserException( |
||
| 64 | Yii::t('app.msg', 'An error occurred while sending a message to activate account') |
||
| 65 | ); |
||
| 66 | } |
||
| 67 | } |
||
| 68 | } |
||
| 69 |