diff --git a/app/Http/Livewire/Team/Delete.php b/app/Http/Livewire/Team/Delete.php index 32e386ebc..b09395df4 100644 --- a/app/Http/Livewire/Team/Delete.php +++ b/app/Http/Livewire/Team/Delete.php @@ -12,7 +12,6 @@ class Delete extends Component $currentTeam = currentTeam(); $currentTeam->delete(); - $team = auth()->user()->teams()->first(); $currentTeam->members->each(function ($user) use ($currentTeam) { if ($user->id === auth()->user()->id) { return; diff --git a/app/Models/User.php b/app/Models/User.php index 1671db496..7df134408 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -78,7 +78,7 @@ class User extends Authenticatable implements SendsEmail if ($is_part_of_root_team && $is_admin_of_root_team) { return true; } - $role = $teams->where('id', auth()->user()->id)->first()->pivot->role; + $role = $teams->where('id', session('currentTeam')->id)->first()->pivot->role; return $role === 'admin' || $role === 'owner'; } diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.php index f42ac83d7..ad449e3c7 100644 --- a/bootstrap/helpers/shared.php +++ b/bootstrap/helpers/shared.php @@ -2,6 +2,7 @@ use App\Models\InstanceSettings; use App\Models\Team; +use App\Models\User; use App\Notifications\Channels\DiscordChannel; use App\Notifications\Channels\EmailChannel; use App\Notifications\Channels\TelegramChannel; @@ -60,7 +61,7 @@ function showBoarding(): bool function refreshSession(?Team $team = null): void { if (!$team) { - $team = Team::find(currentTeam()->id); + $team = User::find(auth()->user()->id)->teams->first(); } Cache::forget('team:' . auth()->user()->id); Cache::remember('team:' . auth()->user()->id, 3600, function() use ($team) {