Skip to content

Standalone actions ignores resource policy #4575

@Nks

Description

@Nks
  • Laravel Version: 9.20.0
  • Nova Version: 4.12.6
  • PHP Version: 8.1.8
  • Database Driver & Version: percona:8.0.26-16
  • Operating System and Version: Debian GNU/Linux 10
  • Browser type and version: Any

Description:

Following this documentation for the actions when using an Action in standalone mode and Policy for a model with a runAction method, the Policy is ignored and is not executed. For inline actions or "mass selection" everything works as expected.

Detailed steps to reproduce the issue on a fresh Nova installation:

  • Create any action with nova:action ActionName
  • Add action to actions method of the resource:
public function actions(NovaRequest $request)
  {
      return [
          (new Actions\ActionName)->standalone(),
      ];
  }
  • Create a model policy with php artisan make:policy
  • Add following code to created policy:
public function runAction(Model $model, $action): bool
{
    return false;
}
  • Run action from the resource list page

Expected result:

  • Actions can not be run by the user

Actual result:

  • Actions executing

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions