當前位置: 首頁>>代碼示例>>PHP>>正文


PHP filters\AccessControl類代碼示例

本文整理匯總了PHP中yii\filters\AccessControl的典型用法代碼示例。如果您正苦於以下問題:PHP AccessControl類的具體用法?PHP AccessControl怎麽用?PHP AccessControl使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了AccessControl類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: behaviors

 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     $behaviors = parent::behaviors();
     $behaviors['access'] = ['class' => AccessControl::className(), 'rules' => [['actions' => ['sign-in', 'sign-up', 'forgot', 'error'], 'allow' => true], ['actions' => ['sign-out', 'update', 'view'], 'allow' => true, 'roles' => ['@']]]];
     $behaviors['verbs'] = ['class' => VerbFilter::className(), 'actions' => ['sign-out' => ['post']]];
     return $behaviors;
 }
開發者ID:frostiks25,項目名稱:rzwebsys7,代碼行數:10,代碼來源:UserController.php

示例2: behaviors

 public function behaviors()
 {
     return ['verbs' => ['class' => VerbFilter::className(), 'actions' => ['delete' => ['post']]], 'access' => ['class' => AccessControl::className(), 'only' => ['create', 'update'], 'rules' => [['actions' => ['create'], 'allow' => true, 'roles' => ['user']], ['actions' => ['update'], 'allow' => true, 'matchCallback' => function ($rule, $action) {
         $model = $this->findModel(Yii::$app->getRequest()->get('id'));
         return Yii::$app->getUser()->can('updateNews', ['model' => $model]);
     }]]]];
 }
開發者ID:obedkin,項目名稱:atlant,代碼行數:7,代碼來源:DefaultController.php

示例3: behaviors

 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return [
         'access' => [
             'class' => AccessControl::className(),
             'rules' => [
                 [
                     'actions' => ['login', 'error'],
                     'allow' => true,
                 ],
                 [
                     'actions' => ['logout', 'index'],
                     'allow' => true,
                     'roles' => ['@'],
                 ],
             ],
         ],
         'verbs' => [
             'class' => VerbFilter::className(),
             'actions' => [
                 'logout' => ['get'],
             ],
         ],
     ];
 }
開發者ID:seans888,項目名稱:SMF-Project,代碼行數:28,代碼來源:SiteController.php

示例4: behaviors

 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return ['access' => ['class' => AccessControl::className(), 'except' => ['index', 'error'], 'rules' => [['allow' => true, 'roles' => ['@']], ['allow' => true, 'actions' => ['download-attachment', 'index', 'search-cluster', 'search-marker', 'info-window', 'view', 'qr-code', 'error'], 'roles' => ['?']]]], 'verbs' => ['class' => VerbFilter::className(), 'actions' => ['delete' => ['post'], 'attachment-delete' => ['post'], 'gallery-delete' => ['post']]], ['class' => 'yii\\filters\\HttpCache', 'only' => ['view'], 'etagSeed' => function ($action, $params) {
         $model = $this->findModel((int) Yii::$app->request->get('id'));
         return serialize([$model->id, $model->updated_at]);
     }]];
 }
開發者ID:rocketyang,項目名稱:admap,代碼行數:10,代碼來源:AdverController.php

示例5: behaviors

 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return [
         'access' => [
             'class' => AccessControl::className(),
             'only' => ['logout', 'signup'],
             'rules' => [
                 [
                     'actions' => ['signup'],
                     'allow' => true,
                     'roles' => ['@'],
                 ],
                 [
                     'actions' => ['logout'],
                     'allow' => true,
                     'roles' => ['@'],
                 ],
             ],
         ],
         'verbs' => [
             'class' => VerbFilter::className(),
             'actions' => [
                 'logout' => ['post'],
             ],
         ],
     ];
 }
開發者ID:seans888,項目名稱:SMF-Project,代碼行數:30,代碼來源:SiteController.php

示例6: behaviors

 /**
  * Returns a list of behaviors that this component should behave as.
  * Here we use RBAC in combination with AccessControl filter.
  *
  * @return array
  */
 public function behaviors()
 {
     return ['access' => ['class' => AccessControl::className(), 'rules' => [['actions' => ['index', 'view', 'create', 'update', 'delete', 'admin'], 'allow' => true, 'roles' => ['editor', 'admin'], 'denyCallback' => function ($rule, $action) {
         return $this->redirect('/', 301);
     }], []]]];
     // return
 }
開發者ID:nmb007,項目名稱:excursion,代碼行數:13,代碼來源:PostController.php

示例7: behaviors

    public function behaviors(){

        $behaviors = [
            'access' => [
                'class' => AccessControl::className(),
                'rules' => [
                    [
                        'allow' => true,
                        'roles' => ['@']
                    ]
                ]
            ],

            'verbs' => [
                'class' => VerbFilter::className(),
                'actions' => [
                    'delete' => ['post'],
                ],
            ],
        ];


        return $behaviors;

    }
開發者ID:scorp7mix,項目名稱:yii,代碼行數:25,代碼來源:AuthController.php

示例8: behaviors

 public function behaviors()
 {
     return ['access' => ['class' => AccessControl::className(), 'rules' => [['allow' => true, 'roles' => ['@']], ['actions' => ['error'], 'allow' => true]], 'denyCallback' => function ($rules, $action) {
         Yii::$app->user->returnUrl = Yii::$app->request->url;
         return $this->redirect(['user/login']);
     }]];
 }
開發者ID:tqsq2005,項目名稱:yga,代碼行數:7,代碼來源:HomeController.php

示例9: behaviors

 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     $behavior = ['access' => ['class' => AccessControl::className(), 'rules' => [['allow' => true, 'roles' => [wanhunet::$app->controller->getRoute()]]], 'denyCallback' => function ($rule, $action) {
         throw new ForbiddenHttpException();
     }]];
     return ArrayHelper::merge($behavior, parent::behaviors());
 }
開發者ID:suyuanen,項目名稱:p2p,代碼行數:10,代碼來源:BackendController.php

示例10: behaviors

 public function behaviors()
 {
     return ['access' => ['class' => AccessControl::className(), 'denyCallback' => function ($rule, $action) {
         \Yii::$app->user->logout();
         $this->redirect(['/users/backend/login']);
     }, 'rules' => [['actions' => ['error'], 'allow' => true], ['actions' => ['index'], 'allow' => true, 'roles' => ['manager', 'admin']]]]];
 }
開發者ID:andreosoft,項目名稱:andreocms,代碼行數:7,代碼來源:BackendController.php

示例11: behaviors

 public function behaviors()
 {
     //        return parent::behaviors(); // TODO: Change the autogenerated stub
     return ['access' => ['class' => \yii\filters\AccessControl::className(), 'only' => ['index'], 'rules' => [['actions' => ['index'], 'allow' => true, 'roles' => ['@'], 'matchCallback' => function ($rule, $action) {
         return PermissionHelpers::requireStatus('Active');
     }]]], 'verbs' => ['class' => VerbFilter::className(), 'actions' => ['delete' => ['post']]]];
 }
開發者ID:kodiers,項目名稱:yii2build,代碼行數:7,代碼來源:UpgradeController.php

示例12: behaviors

 public function behaviors()
 {
     return ['verbs' => ['class' => VerbFilter::className(), 'actions' => ['delete' => ['post']]], 'access' => ['class' => AccessControl::className(), 'only' => ['index', 'create', 'update', 'delete'], 'rules' => [['allow' => true, 'actions' => ['index', 'create', 'update', 'delete'], 'roles' => ['@']]], 'denyCallback' => function ($rule, $action) {
         return $this->redirect(['/site/login']);
         throw new HttpException(403, Yii::t('yii', 'Login Required'));
     }]];
 }
開發者ID:pham186,項目名稱:yii2,代碼行數:7,代碼來源:PostController.php

示例13: behaviors

 public function behaviors()
 {
     return ['access' => ['class' => AccessControl::className(), 'only' => ['create', 'index'], 'rules' => [['actions' => ['error'], 'allow' => true, 'roles' => ['10']], ['actions' => ['logout', 'create', 'index'], 'allow' => true, 'roles' => ['@']], ['actions' => ['about'], 'allow' => true, 'roles' => ['@'], 'matchCallback' => function ($rule, $action) {
         $valid_roles = [User::ROLE_ADMIN, User::ROLE_SUPERUSER];
         return User::roleInArray($valid_roles) && User::isActive();
     }]]], 'verbs' => ['class' => VerbFilter::className(), 'actions' => ['logout' => ['post']]]];
 }
開發者ID:krispaz,項目名稱:appsinsch,代碼行數:7,代碼來源:FactencuestaController.php

示例14: behaviors

 public function behaviors()
 {
     return ['access' => ['class' => AccessControl::className(), 'ruleConfig' => ['class' => AccessRule::className()], 'rules' => [['allow' => true, 'roles' => [UserCadastro::ROLE_ADMIN]]]]];
     //            [ 'access' => [
     //                'class' => AccessControl::className(),
     //                'only' => ['index', 'view'],
     //                'rules' => [
     //                    [
     //                        'actions' => ['index','view'],
     //                        'allow' => true,
     //                        'roles' => ['@'],
     //                    ],
     //
     //                ],
     //            ],
     //				'verbs' => [
     //						'class' => VerbFilter::className (),
     //						'actions' => [
     //								'delete' => [
     //										'post'
     //								]
     //						]
     //				]
     //		];
 }
開發者ID:dieos2,項目名稱:bolaoyyi2,代碼行數:25,代碼來源:UserController.php

示例15: behaviors

 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return ['access' => ['class' => AccessControl::className(), 'only' => ['index', 'delete'], 'rules' => [['allow' => true, 'actions' => ['index', 'delete'], 'roles' => ['@'], 'matchCallback' => function () {
         //Llamada al método que comprueba si es un vendedor
         return \common\models\User::isUserAdmin(Yii::$app->user->identity->id);
     }]]], 'verbs' => ['class' => VerbFilter::className(), 'actions' => ['delete' => ['POST']]]];
 }
開發者ID:rvences,項目名稱:mopoua,代碼行數:10,代碼來源:TipoingresoegresoController.php


注:本文中的yii\filters\AccessControl類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。