作者:frostiks2
项目:rzwebsys
/**
* @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;
}
作者:obedki
项目:atlan
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]);
}]]]];
}
作者:seans88
项目:SMF-Projec
/**
* @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'],
],
],
];
}
作者:rocketyan
项目:adma
/**
* @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]);
}]];
}
作者:seans88
项目:SMF-Projec
/**
* @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'],
],
],
];
}
作者:nmb00
项目:excursio
/**
* 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
}
作者:scorp7mi
项目:yi
public function behaviors(){
$behaviors = [
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'allow' => true,
'roles' => ['@']
]
]
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['post'],
],
],
];
return $behaviors;
}
作者:tqsq200
项目:yg
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']);
}]];
}
作者:suyuane
项目:p2
/**
* @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());
}
作者:andreosof
项目:andreocm
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']]]]];
}
作者:kodier
项目:yii2buil
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']]]];
}
作者:pham18
项目:yii
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'));
}]];
}
作者:krispa
项目:appsinsc
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']]]];
}
作者:dieos
项目:bolaoyyi
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'
// ]
// ]
// ]
// ];
}
作者:rvence
项目:mopou
/**
* @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']]]];
}
作者:suyuane
项目:p2
/**
* @inheritdoc
*/
public function behaviors()
{
return ['access' => ['class' => AccessControl::className(), 'except' => ['get-captcha', 'signup', 'signin', 'signup-verify', 'login', 'off', 'enter', 'pay-notify', 'notify', 'list', 'view', 'wechat', 'create-menu'], 'rules' => [['allow' => true, 'roles' => ['@']]], 'denyCallback' => function () {
wanhunet::$app->getSession()->setFlash("errors", ['info' => '请先登录']);
return $this->redirect(Url::to(['site/signin']));
}]];
}
作者:gbksof
项目:yii2-token
/**
* @inheritdoc
*/
public function behaviors()
{
$event = new \yii\base\Event();
$event->data = [];
$this->module->trigger(self::EVENT_BEFORE_BEHAVIOR, $event);
return ArrayHelper::merge(parent::behaviors(), $event->data, ['access' => ['class' => AccessControl::className(), 'rules' => [['allow' => true, 'actions' => ['options'], 'roles' => ['?']], ['allow' => true, 'actions' => ['create', 'view', 'current', 'extend'], 'roles' => ['@']]]]]);
}
作者:wuwenha
项目:huoqiwan
public function behaviors()
{
return ['access' => ['class' => AccessControl::className(), 'except' => ['signup', 'signin', 'member', 'index', 'login', 'logout', 'createmenu', 'enter', 'main', 'detaile', 'step1', 'step2', 'reg', 'dosignin', 'forgot', 'forgotstep1', 'forgotfinish', 'bindcard', 'about', 'help', 'contact', 'safety', 'gindex', 'gshare', 'gsignup', 'dorecharge', 'productlist'], 'rules' => [['allow' => true, 'roles' => ['@']]], 'denyCallback' => function () {
\Yii::$app->getSession()->setFlash("errors", ['info' => '']);
return $this->redirect(Url::to(['site/signin']));
}]];
}
作者:afernandes46
项目:memoboar
public function behaviors()
{
return ['access' => ['class' => AccessControl::className(), 'only' => ['logout'], 'rules' => [['actions' => ['logout'], 'allow' => true, 'roles' => ['@'], 'denyCallback' => function () {
//redirect here
return $this->redirect('message');
}]]], 'verbs' => ['class' => VerbFilter::className(), 'actions' => ['logout' => ['post']]]];
}
作者:zxva
项目:PriceCalculationOfCircuitBoard
public function behaviors()
{
$behaviors = parent::behaviors();
$behaviors['authenticator'] = ['class' => HttpBearerAuth::className()];
$behaviors['access'] = ['class' => AccessControl::className(), 'only' => ['create', 'index', 'update', 'delete'], 'rules' => [['allow' => true, 'actions' => ['create', 'index', 'update', 'delete'], 'roles' => ['ADMIN']]]];
return $behaviors;
}