作者:WondersLabCorporatio
项目:yii
/**
* @inheritdoc
*/
public function behaviors()
{
$behaviors = parent::behaviors();
$behaviors['access']['rules'] = array_merge([['actions' => ['login'], 'allow' => true, 'roles' => ['?']], ['actions' => ['login'], 'allow' => false, 'roles' => ['@']], ['actions' => ['logout'], 'allow' => true, 'roles' => ['@']], ['actions' => ['logout'], 'allow' => false, 'roles' => ['?']]], $behaviors['access']['rules']);
$behaviors['verbs'] = ['class' => VerbFilter::className(), 'actions' => ['logout' => ['post']]];
return $behaviors;
}
作者: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'],
],
],
];
}
作者: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]);
}]]]];
}
作者: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']]]];
}
作者: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;
}
作者:navatec
项目:yii2-roxymc
/**
* {@inheritDoc}
*/
public function behaviors()
{
$behaviors = parent::behaviors();
$behaviors['contentNegotiator'] = ['class' => ContentNegotiator::className(), 'formats' => ['application/json' => Response::FORMAT_JSON]];
$behaviors['verbs'] = ['class' => VerbFilter::className(), 'actions' => ['*' => ['GET', 'AJAX'], 'file-upload' => ['POST', 'AJAX']]];
return $behaviors;
}
作者: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'],
],
],
];
}
作者:soann
项目:stocks_mv
public function behaviors()
{
$behaviors = parent::behaviors();
$behaviors['verbs'] = ['class' => VerbFilter::className(), 'actions' => ['indexWithQuote' => ['get']]];
$behaviors['authenticator'] = ['class' => HttpBasicAuth::className()];
return $behaviors;
}
作者:scorp7mi
项目:yi
public function behaviors(){
$behaviors = [
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'allow' => true,
'roles' => ['@']
]
]
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['post'],
],
],
];
return $behaviors;
}
作者:sindotne
项目:con
public function behaviors()
{
if (Yii::$app->user->identity->type == 'normal') {
return $this->goBack();
}
return ['verbs' => ['class' => VerbFilter::className(), 'actions' => ['delete' => ['post']]]];
}
作者:booki
项目:yii2-rest-exampl
public function behaviors()
{
$behaviors = parent::behaviors();
$behaviors['rateLimiter'] = ['class' => RateLimiter::className(), 'only' => ['view']];
$behaviors['verbs'] = ['class' => VerbFilter::className(), 'actions' => ['view' => ['get'], 'countries' => ['get'], 'cities' => ['get']]];
return $behaviors;
}
作者: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'));
}]];
}
作者:adem-tea
项目:advancedgs
/**
* @inheritdoc
*/
public function behaviors()
{
return ['verbs' => ['class' => VerbFilter::className(['send']), 'actions' => ['delete' => ['POST']]]];
/* return [
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
/* Author: -ptr.nov- : Permission Allow No Login |index|error|login */
/* 'actions' => ['index', 'error','login','subcat','site'],
'allow' => true,
],
[
'actions' => ['logout', 'index','subcat','site'],
'allow' => true,
'roles' => ['@'],
],
],
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'logout' => ['post'],
],
],
];
*/
}
作者: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]);
}]];
}
作者:artkos
项目:yii2-starter-ki
/**
* @inheritdoc
*/
public function behaviors()
{
$behaviors = parent::behaviors();
$behaviors['access']['rules'] = ArrayHelper::merge($behaviors['access']['rules'], [['allow' => true, 'actions' => ['index'], 'roles' => ['pageView']], ['allow' => true, 'actions' => ['create'], 'roles' => ['pageCreate']], ['allow' => true, 'actions' => ['update'], 'roles' => ['pageUpdate']], ['allow' => true, 'actions' => ['delete', 'batch-delete'], 'roles' => ['pageDelete']]]);
$behaviors['verbs'] = ['class' => VerbFilter::className(), 'actions' => ['index' => ['get'], 'update' => ['get', 'put', 'post'], 'delete' => ['post', 'delete'], 'batch-delete' => ['post', 'delete']]];
return $behaviors;
}
作者:kostya-sk
项目:enrolle
/**
* @inheritdoc
*/
public function behaviors()
{
return ['access' => ['class' => AccessControl::className(), 'only' => ['profile', 'return-to-edit', 'profile-to-pdf', 'spec-list', 'spec-items', 'agreement'], 'rules' => [['actions' => ['profile', 'return-to-edit', 'profile-to-pdf', 'spec-list', 'spec-items', 'agreement'], 'allow' => true, 'roles' => ['@']]]], 'verbs' => ['class' => VerbFilter::className(), 'actions' => ['return-to-edit' => ['post']]], ['class' => \yii\filters\HttpCache::className(), 'only' => ['view'], 'lastModified' => function ($action, $params) {
$q = new \yii\db\Query();
return $q->from('profile')->max('updated_at');
}]];
}
作者: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']]]];
}
作者: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']]]];
}
作者:KokLi
项目:GS
public function behaviors()
{
$index = '';
$view = '';
$update = '';
$create = '';
$delete = '';
if (!Yii::$app->user->isGuest) {
$uid = Yii::$app->user->identity->user_id;
$accessIndex = Access2::find()->where(['user_id' => $uid, 'sub_module_id' => 30])->one();
$accessView = Access2::find()->where(['user_id' => $uid, 'sub_module_id' => 31])->one();
$accessCreate = Access2::find()->where(['user_id' => $uid, 'sub_module_id' => 32])->one();
$accessUpdate = Access2::find()->where(['user_id' => $uid, 'sub_module_id' => 33])->one();
$accessDelete = Access2::find()->where(['user_id' => $uid, 'sub_module_id' => 34])->one();
if ($accessIndex != NULL) {
$index = 'index';
}
if ($accessView != NULL) {
$view = 'view';
}
if ($accessUpdate != NULL) {
$update = 'update';
}
if ($accessCreate != NULL) {
$create = 'create';
}
if ($accessDelete != NULL) {
$delete = 'delete';
}
}
return ['access' => ['class' => AccessControl::className(), 'only' => ['index', 'view', 'create', 'update', 'delete'], 'rules' => [['allow' => false, 'roles' => ['?']], ['allow' => true, 'actions' => [$index, $view, $create, $update, $delete], 'roles' => ['@']]]], 'verbs' => ['class' => VerbFilter::className(), 'actions' => ['delete' => ['post']]]];
}