Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Policy is evaluated twice when running actions #6167

Closed
Timisorean opened this issue Jan 29, 2024 · 2 comments
Closed

Policy is evaluated twice when running actions #6167

Timisorean opened this issue Jan 29, 2024 · 2 comments
Labels
needs more info More information is required

Comments

@Timisorean
Copy link

  • Laravel Version: 10.42.0
  • Nova Version: 4.32.11
  • PHP Version: 8.2

Description:

(new CancelBooking)
    ->confirmButtonText('Cancel')
    ->canSeeWhen('cancel', $this),

We using canSeeWhen to restrict which actions can bee seen/run for users. But we encountered an issue getting 403 when calling the action. It appears that the policy gets called twice with different models. The first call is done with the correct model object that is loaded from the database. Therefore the user can see and run the action. The second call has an empty model object with only default attributes that is not loaded from the database. Meaning that the exists attribute is set to false. We fixed it by just checking the exists attribute every policy method. But that is an tedious solution. Is this expected behavior.

@crynobone
Copy link
Member

Unable to reproduce the issue, please provide full reproducing repository based on fresh installation as suggested in the bug report template (or you can refer to https://github.com/nova-issues for example)

@crynobone crynobone added the needs more info More information is required label Feb 12, 2024
@crynobone
Copy link
Member

Hey there,

We're closing this issue because it's inactive, already solved, old, or not relevant anymore. Feel free to open up a new issue if you're still experiencing this problem.

@crynobone crynobone closed this as not planned Won't fix, can't repro, duplicate, stale Feb 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs more info More information is required
Projects
None yet
Development

No branches or pull requests

2 participants