I would check the format of the post url and compare that to your routes.
Sounds like perhaps something else is grabbing the route?
You are not uploading a large file with the update?
I have an AddressController that has your standard resource methods. I have validation via StoreAddressRequest and UpdateAddressRequest classes. I have implemented authorization via a model related policy class - AddressPolicy.
At present all of the resource methods are only accessible to the admin user via the AddressPolicy - checking this with an admin user and standard user shows that Index,Create,Store and Edit all work great.
However, when I try to update an address as an Admin user I get the following message:
Symfony \ Component \ HttpKernel \ Exception \ AccessDeniedHttpException
This action is unauthorized.
Checking debugbar reveals:
error
array:4 [▼
"ability" => "update"
"result" => false
"user" => 1
"arguments" => "[0 => Object(App\User)]"
]
This is the correct user. My session has not expired when making the request.
I am calling the policy in the same way as I do for index,show,create,store and edit eg:
$this->authorize('update', \Auth::user());
and then within AddressPolicy:
public function update(User $user)
{
if ($user->isSuperAdmin()) {
return true;
} else {
return false;
}
}
I am not certain the update function is getting invoked, since, if I remove the 'update' method from the AddressPolicy I still get the same message. Also, I cannot dd() from within a method in the AddressPolicy.
Clearly I have messed up somewhere! Thanks for any pointers.
Please or to participate in this conversation.