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