mirror of
https://github.com/elyby/accounts.git
synced 2026-11-25 00:33:13 +05:30
Реализованы методы для включения\отключения двухфакторной аутентификации
This commit is contained in:
1 parent
3b9ef7ea70
commit
be4c7908b2
4 files changed
+83
-5
No files matched your search
@@ -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,
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user