I am getting This action is unauthorized 403 when i enter url localhost/website/post/1/edit. i want to protect to edit post from unauthorized user .
in PostController
public function edit($id)
{
$post=Post::findOrFail($id);
$this->authorize('check_access',$post);
return 'You are authorized';
}
In AuthServiceProvider.php
protected $policies = [
Post::class => 'PostPolicy::class',
];
in PostPolicy.php
public function check_access($post)
{
return Auth::user()->id==$post->user_id;
}
In web.php Route::resource('post','PostController');
Please Tell Where i am wrong . i am new in laravel and totally frustrated. Thanks
from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2Spq7DY
via IFTTT
Aucun commentaire:
Enregistrer un commentaire