Interface luya\rest\UserBehaviorInterface
REST User Behavior Interface.
The iplementation of the UserBeavhiorInterface should come along with the {{luya\traits\RestBehaviorsTrait}}.
An example integration:
class MyRestController extends \luya\rest\Controller implements \luya\rest\UserBehaviorInterface
{
use \luya\traits\RestBehaviorTrait; // Use is already done by the \luya\rest\Controller class.
public function userAuthClass()
{
return Yii::$app->user;
}
// Is action is now secured by the `app\models\User` model.
public function actionIndex()
{
return ['foo' => 'bar'];
}
}
Public Methods
Method | Description | Defined By |
---|---|---|
userAuthClass() | Returns the class object for the authentication of the rest api. If the return value is false the authentication is disabled for the whole rest controller. | luya\rest\UserBehaviorInterface |
Method Details
Returns the class object for the authentication of the rest api. If the return value is false the authentication is disabled for the whole rest controller.
return a user object (based on {{yii\web\User}}):
return Yii::$app->adminuser;
return a class string will create a new object from this class string:
return \luya\admin\components\AdminUser::class;
return false will disabled the authentication proccess for this rest controller:
return false;
It can also be an array with configurations:
return [
'class' => 'app\models\User',
'property1' => 'value',
];
public abstract boolean|string|yii\web\User userAuthClass ( ) | ||
return | boolean|string|yii\web\User |
If |
---|
public function userAuthClass();