@@ 62-69 (lines=8) @@ | ||
59 | { |
|
60 | /** @var MfaIdentityInterface $user */ |
|
61 | $user = Yii::$app->user->identity; |
|
62 | if ($user->getTotpSecret()) { |
|
63 | Yii::$app->session->setFlash( |
|
64 | 'error', |
|
65 | Yii::t('mfa', 'Two-factor authentication is already enabled. Disable first.') |
|
66 | ); |
|
67 | ||
68 | return empty($back) ? $this->goHome() : $this->deferredRedirect($back); |
|
69 | } |
|
70 | ||
71 | $model = new InputForm(); |
|
72 | $secret = $this->module->getTotp()->getSecret(); |
|
@@ 98-108 (lines=11) @@ | ||
95 | ); |
|
96 | ||
97 | return empty($back) ? $this->goBack() : $this->deferredRedirect($back); |
|
98 | } else { |
|
99 | Yii::$app->session->setFlash( |
|
100 | 'error', |
|
101 | Yii::t( |
|
102 | 'mfa', |
|
103 | 'Sorry, we have failed to enable two-factor authentication.' |
|
104 | ) |
|
105 | ); |
|
106 | ||
107 | return empty($back) ? $this->goHome() : $this->deferredRedirect($back); |
|
108 | } |
|
109 | } else { |
|
110 | $model->addError( |
|
111 | 'code', |
|
@@ 124-131 (lines=8) @@ | ||
121 | ||
122 | public function actionCodes(array $codes, $back = null) |
|
123 | { |
|
124 | if (Yii::$app->request->post('mfa-codes-saved')) { |
|
125 | Yii::$app->session->setFlash( |
|
126 | 'success', |
|
127 | Yii::t('mfa', 'Two-factor authentication successfully enabled.') |
|
128 | ); |
|
129 | ||
130 | return empty($back) ? $this->goBack() : $this->deferredRedirect($back); |
|
131 | } |
|
132 | ||
133 | return $this->render('codes', compact('codes')); |
|
134 | } |