|
@@ 56-60 (lines=5) @@
|
| 53 |
|
public function actionEnable($back = null) |
| 54 |
|
{ |
| 55 |
|
$user = Yii::$app->user->identity; |
| 56 |
|
if ($user->totp_secret) { |
| 57 |
|
Yii::$app->session->setFlash('error', Yii::t('mfa', 'Two-factor authentication is already enabled. Disable first.')); |
| 58 |
|
|
| 59 |
|
return empty($back) ? $this->goHome() : $this->deferredRedirect($back); |
| 60 |
|
} |
| 61 |
|
|
| 62 |
|
$model = new InputForm(); |
| 63 |
|
$secret = $this->module->getTotp()->getSecret(); |
|
@@ 73-77 (lines=5) @@
|
| 70 |
|
Yii::$app->session->setFlash('success', Yii::t('mfa', 'Two-factor authentication successfully enabled.')); |
| 71 |
|
|
| 72 |
|
return empty($back) ? $this->goBack() : $this->deferredRedirect($back); |
| 73 |
|
} else { |
| 74 |
|
Yii::$app->session->setFlash('error', Yii::t('mfa', 'Sorry, we have failed to enable two-factor authentication.')); |
| 75 |
|
|
| 76 |
|
return empty($back) ? $this->goHome() : $this->deferredRedirect($back); |
| 77 |
|
} |
| 78 |
|
} else { |
| 79 |
|
$model->addError('code', Yii::t('mfa', 'Wrong verification code. Please verify your secret and try again.')); |
| 80 |
|
} |