Open desaikalpesh34 opened 7 years ago
Are you sure the error come from AccessControl
?
Yes
what the error?
before adding behavior its work perfectly http://prntscr.com/dgc8di
when i am adding behavior then errors show like http://prntscr.com/dgc7xk
in frontend and backend work perfectly and as expected.
m i missing something or there is bug??
any thought??
I have solved this by configuring Controller behavior... like
<?php
namespace api\modules\v1\controllers;
use Yii;
use yii\rest\Controller;
class HelloController extends Controller
{
public function behaviors()
{
$behaviors = parent::behaviors();
$behaviors['authenticator'] = [
'class' => CompositeAuth::className(),
'authMethods' => [
[
'class' => HttpBasicAuth::className(),
'auth' => function ($username, $password) {
$user = User::findByLogin($username);
return $user->validatePassword($password)
? $user
: null;
}
],
HttpBearerAuth::className(),
QueryParamAuth::className()
],
];
$behaviors['access'] = [
'class' => 'mdm\admin\components\AccessControl',
];
return $behaviors;
}
public function actionIndex()
{
return Yii::$app->id;
}
}
and its working like charm. Thank you @mdmunir
Hey this module does not support for rest api controller
I have configured api like
its break down my app. is there extra setting required??