I need to block users from visualizing other users profiles I have the following in my web.php:
Route::get('companyuser/{id}', [CompanyUserController::class, 'show'])
->middleware(['role:companyuser', 'can:show,user']);
I defined a policy
public function show(User $authenticatedUser, $user_model)
{
return $authenticatedUser === $user_model->id ? Response::allow() : Response::deny();
}
and added it to the AuthServiceProvider
protected $policies = [
'App\Model' => 'App\Policies\ModelPolicy',
User::class => CompanyUserPolicy::class,
];
But now the user is blocked from entering his own profile as well. What am I missing? Thanks for the help.