Tenancy Check in Model Policy

My Policy has the following code:
public function view(User $user, Model $model): bool
{
return $user->hasRole(Roles::SUPER_ADMIN)
|| (Filament::getTenant()->id === $user->tenant_id && $user->model->id == $model->id);
}
public function view(User $user, Model $model): bool
{
return $user->hasRole(Roles::SUPER_ADMIN)
|| (Filament::getTenant()->id === $user->tenant_id && $user->model->id == $model->id);
}
Is this the correct way? I am using PrivateChannel for Broadcasting and Authorization is failing because. /broadcasting/auth isn't aware of the tenant. Authorization callback does a check if user can view model $user->can('view', Model::find($id)); Any solution to make this work?
0 Replies
No replies yetBe the first to reply to this messageJoin