| Conditions | 4 |
| Paths | 4 |
| Total Lines | 18 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 18 | public function setConfirmed(string $token): void |
||
| 19 | { |
||
| 20 | $tokenizer = new Tokenizer(); |
||
| 21 | |||
| 22 | if ($tokenizer->validate($token)) { |
||
| 23 | $user = User::find()->emailConfirmToken($token)->one(); |
||
| 24 | |||
| 25 | if ($user) { |
||
| 26 | $user->setConfirmed(); |
||
| 27 | if (!$user->save()) { |
||
| 28 | throw new Exception(Yii::t('app.msg', 'An error occurred while confirming')); |
||
| 29 | } |
||
| 30 | return; |
||
| 31 | } |
||
| 32 | } |
||
| 33 | |||
| 34 | throw new BadRequestHttpException(Yii::t('app.msg', 'Invalid token for activate account')); |
||
| 35 | } |
||
| 36 | |||
| 67 |