|
@@ 86-90 (lines=5) @@
|
| 83 |
|
{ |
| 84 |
|
/** @var MfaIdentityInterface $user */ |
| 85 |
|
$user = Yii::$app->user->identity; |
| 86 |
|
if ($user->getTotpSecret()) { |
| 87 |
|
Yii::$app->session->setFlash('error', Yii::t('mfa', 'Two-factor authentication is already enabled. Disable first.')); |
| 88 |
|
|
| 89 |
|
return empty($back) ? $this->goHome() : $this->deferredRedirect($back); |
| 90 |
|
} |
| 91 |
|
|
| 92 |
|
$model = new InputForm(); |
| 93 |
|
$secret = $this->module->getTotp()->getSecret(); |
|
@@ 103-107 (lines=5) @@
|
| 100 |
|
Yii::$app->session->setFlash('success', Yii::t('mfa', 'Two-factor authentication successfully enabled.')); |
| 101 |
|
|
| 102 |
|
return empty($back) ? $this->goBack() : $this->deferredRedirect($back); |
| 103 |
|
} else { |
| 104 |
|
Yii::$app->session->setFlash('error', Yii::t('mfa', 'Sorry, we have failed to enable two-factor authentication.')); |
| 105 |
|
|
| 106 |
|
return empty($back) ? $this->goHome() : $this->deferredRedirect($back); |
| 107 |
|
} |
| 108 |
|
} else { |
| 109 |
|
$model->addError('code', Yii::t('mfa', 'Wrong verification code. Please verify your secret and try again.')); |
| 110 |
|
} |