Реализованы методы для включения\отключения двухфакторной аутентификации

This commit is contained in:
ErickSkrauch
2017-01-21 02:28:26 +03:00
parent 3b9ef7ea70
commit be4c7908b2
4 changed files with 83 additions and 5 deletions

View File

@ -34,4 +34,34 @@ class TwoFactorAuthController extends Controller {
return $model->getCredentials();
}
public function actionActivate() {
$account = Yii::$app->user->identity;
$model = new TwoFactorAuthForm($account, ['scenario' => TwoFactorAuthForm::SCENARIO_ACTIVATE]);
if (!$model->activate()) {
return [
'success' => false,
'errors' => $model->getFirstErrors(),
];
}
return [
'success' => true,
];
}
public function actionDisable() {
$account = Yii::$app->user->identity;
$model = new TwoFactorAuthForm($account, ['scenario' => TwoFactorAuthForm::SCENARIO_DISABLE]);
if (!$model->disable()) {
return [
'success' => false,
'errors' => $model->getFirstErrors(),
];
}
return [
'success' => true,
];
}
}