Browse Source

feat:增加获取权限方法

antshop
linyaostalker 5 years ago
parent
commit
86312e14dc
  1. 22
      backend/controllers/SiteController.php

22
backend/controllers/SiteController.php

@ -3,16 +3,17 @@
namespace backend\controllers; namespace backend\controllers;
use backend\logic\PermissionManager; use backend\logic\PermissionManager;
use ReflectionException;
use Yii; use Yii;
use yii\base\InvalidConfigException;
use yii\web\Controller; use yii\web\Controller;
use yii\filters\VerbFilter; use yii\filters\VerbFilter;
use yii\filters\AccessControl; use yii\filters\AccessControl;
use backend\models\LoginForm; use backend\models\LoginForm;
use backend\models\CategorySearch;
/** /**
* Site controller * Site controller
* DESCRIBE 网站基本权限 DESCRIBE
* @DESCRIBE 网站基本权限 DESCRIBE
*/ */
class SiteController extends Controller { class SiteController extends Controller {
@ -25,7 +26,7 @@ class SiteController extends Controller {
'class' => AccessControl::className(), 'class' => AccessControl::className(),
'rules' => [ 'rules' => [
[ [
'actions' => ['login', 'error', 'test'],
'actions' => ['login', 'error', 'get-permission'],
'allow' => true, 'allow' => true,
], ],
[ [
@ -71,7 +72,7 @@ class SiteController extends Controller {
* Login action. * Login action.
* *
* @return string * @return string
* ACTION 登录 ACTION
* @ACTION 登录 ACTION
*/ */
public function actionLogin() { public function actionLogin() {
@ -97,7 +98,7 @@ class SiteController extends Controller {
* Logout action. * Logout action.
* *
* @return string * @return string
* ACTION 登出 ACTION
* @ACTION 登出 ACTION
*/ */
public function actionLogout() { public function actionLogout() {
Yii::$app->user->logout(); Yii::$app->user->logout();
@ -105,4 +106,15 @@ class SiteController extends Controller {
return $this->goHome(); return $this->goHome();
} }
/**
* 获取权限
* @return array
* @throws ReflectionException
* @throws InvalidConfigException
*/
public function actionGetPermission()
{
return PermissionManager::getAppPermission();
}
} }
Loading…
Cancel
Save