Policy has not being called

Viewed 53

Policy not being called ((

My Policy class:enter image description here

My AuthServiceProviderenter image description here

i have tried all variants: with guessPolicyName, and manually registered policies...

my Controller:enter image description here

in all cases policy is not even called and AccessDeniedHttpException This action is unauthorized is thrown...

Any ideas?

1 Answers

The problem was in authorization it self because policies doesnt works with guest users. So i decided to use middleware (in my particular case it is better than custom service provider because i have several types of guest users)

this is my middleware classenter image description here

i wrap my guests routes with this middleware

GuestClient is model it should extends from Illuminate\Foundation\Auth\User

the policy class: enter image description here and it works))

Related