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