Добавлен контроллер для блокировки аккаунта

Добавлен client_credentials grant для oAuth
Рефакторинг структуры OauthScopes чтобы можно было разделить владельца прав на пользовательские и общие (машинные)
Исправлена стилистика кода, внедряются фишки PHP 7.1
This commit is contained in:
ErickSkrauch
2016-12-18 02:20:53 +03:00
parent 1e7039c05c
commit 79bbc12206
21 changed files with 332 additions and 68 deletions

View File

@@ -3,7 +3,7 @@ namespace api\modules\internal\controllers;
use api\components\ApiUser\AccessControl;
use api\controllers\Controller;
use api\modules\internal\models\BlockForm;
use api\modules\internal\models\BanForm;
use common\models\Account;
use common\models\OauthScope as S;
use Yii;
@@ -14,11 +14,14 @@ class AccountsController extends Controller {
public function behaviors() {
return ArrayHelper::merge(parent::behaviors(), [
'authenticator' => [
'user' => Yii::$app->apiUser,
],
'access' => [
'class' => AccessControl::class,
'rules' => [
[
'actions' => ['block'],
'actions' => ['ban'],
'allow' => true,
'roles' => [S::ACCOUNT_BLOCK],
],
@@ -27,9 +30,9 @@ class AccountsController extends Controller {
]);
}
public function actionBlock(int $accountId) {
public function actionBan(int $accountId) {
$account = $this->findAccount($accountId);
$model = new BlockForm($account);
$model = new BanForm($account);
$model->load(Yii::$app->request->post());
if (!$model->ban()) {
return [