mirror of
https://github.com/elyby/accounts.git
synced 2025-05-31 14:11:46 +05:30
Добавлен контроллер для блокировки аккаунта
Добавлен client_credentials grant для oAuth Рефакторинг структуры OauthScopes чтобы можно было разделить владельца прав на пользовательские и общие (машинные) Исправлена стилистика кода, внедряются фишки PHP 7.1
This commit is contained in:
@@ -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 [
|
||||
|
Reference in New Issue
Block a user