src/base/RestActiveController.php
public function can($type)
    {
        if (!in_array($type, [Auth::CAN_CREATE, Auth::CAN_DELETE, Auth::CAN_UPDATE, Auth::CAN_VIEW])) {
            throw new InvalidConfigException("Invalid type of permission check.");
        }

        $can = Yii::$app->auth->matchApi($this->userAuthClass()->identity->id, $this->id, $type);

        if (!$can) {
            throw new ForbiddenHttpException("User is unable to access the API due to insufficient permissions.");
        }

        return true;
    }
public function can($type)
    {
        if (!in_array($type, [Auth::CAN_CREATE, Auth::CAN_DELETE, Auth::CAN_UPDATE, Auth::CAN_VIEW])) {
            throw new InvalidConfigException("Invalid type of permission check.");
        }

        $can = Yii::$app->auth->matchApi($this->userAuthClass()->identity->id, $this->id, $type);

        if (!$can) {
            throw new ForbiddenHttpException("User is unable to access the API due to insufficient permissions.");
        }

        return true;
    }
public function can ( $ type ) { if ( ! in_array ( $ type , [ Auth :: CAN_CREATE , Auth :: CAN_DELETE , Auth :: CAN_UPDATE , Auth :: CAN_VIEW ] ) ) { throw new InvalidConfigException ( "Invalid type of permission check." ) ; } $ can = Yii :: $ app -> auth -> matchApi ( $ this -> userAuthClass ( ) -> identity -> id , $ this -> id , $ type ) ; if ( ! $ can ) { throw new ForbiddenHttpException ( "User is unable to access the API due to insufficient permissions." ) ; } return true ; }
Check if the current user have given permissions type.

```php
$this->can(Auth::CAN_UPDATE);
```

If the user has no permission to update a forbidden http exception is thrown.

@param integer $type
@return boolean Returns true otherwise throws an exception
@throws ForbiddenHttpException
@since 2.0.0
Check if the current user have given permissions type .