An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
fix(team): prevent 500 after deleting the current team
Firsakd415f3a3d1e6
diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.phpindex 860b550dd3..011c867441 100644--- a/bootstrap/helpers/shared.php+++ b/bootstrap/helpers/shared.php@@ -353,14 +353,30 @@ function showBoarding(): boolfunction refreshSession(?Team $team = null): void{if (! $team) {- if (Auth::user()->currentTeam()) {- $team = Team::find(Auth::user()->currentTeam()->id);- } else {- $team = User::find(Auth::id())->teams->first();+ $currentTeam = Auth::user()->currentTeam();+ if ($currentTeam) {+ // currentTeam() can resolve a stale (just-deleted) team from the+ // session/cache, so Team::find() may still return null here.+ $team = Team::find($currentTeam->id);+ }+ if (! $team) {+ // Fall back to any team the user still belongs to.+ $team = User::find(Auth::id())->teams()->first();}}+// Clear old cache key format for backwards compatibilityCache::forget('team:'.Auth::id());++ if (! $team) {+ // The user has no team left (e.g. just deleted their current team and+ // belongs to no other): clear the stale session reference instead of+ // dereferencing null.+ session()->forget('currentTeam');++ return;+ }+// Use new cache key format that includes team IDCache::forget('user:'.Auth::id().':team:'.$team->id);Cache::remember('user:'.Auth::id().':team:'.$team->id, 3600, function () use ($team) {