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(auth): keep the current team only in the session
Andras Bacsaidf9f1555b30a
diff --git a/app/Actions/Fortify/CreateNewUser.php b/app/Actions/Fortify/CreateNewUser.phpindex c69863c572..f24b9699f2 100644--- a/app/Actions/Fortify/CreateNewUser.php+++ b/app/Actions/Fortify/CreateNewUser.php@@ -81,7 +81,7 @@ class CreateNewUser implements CreatesNewUsers}}// Set session variable- session(['currentTeam' => $user->currentTeam = $team]);+ session(['currentTeam' => $team]);return $user;}diff --git a/app/Providers/FortifyServiceProvider.php b/app/Providers/FortifyServiceProvider.phpindex 6426860187..50df845f7b 100644--- a/app/Providers/FortifyServiceProvider.php+++ b/app/Providers/FortifyServiceProvider.php@@ -27,7 +27,7 @@ class FortifyServiceProvider extends ServiceProviderpublic function toResponse($request){// First user (root) will be redirected to /settings instead of / on registration.- if ($request->user()->currentTeam->id === 0) {+ if ($request->user()->currentTeam()?->id === 0) {return redirect()->route('settings.index');}@@ -88,9 +88,9 @@ class FortifyServiceProvider extends ServiceProviderif (! $user->teams()->where('team_id', $invitation->team->id)->exists()) {$user->teams()->attach($invitation->team->id, ['role' => $invitation->role]);}- $user->currentTeam = $invitation->team;+ $team = $invitation->team;$invitation->delete();- session(['currentTeam' => $user->currentTeam]);+ session(['currentTeam' => $team]);} else {// Restore the last active team; only fall back when unambiguous.$team = $user->resolveStoredTeam();@@ -98,7 +98,7 @@ class FortifyServiceProvider extends ServiceProvider$team = $user->recreate_personal_team();}if ($team) {- session(['currentTeam' => $user->currentTeam = $team]);+ session(['currentTeam' => $team]);}// Otherwise (multiple teams, no stored choice) leave the session// team unset so the user is sent to the team-selection screen.diff --git a/app/Services/Auth/OauthLoginService.php b/app/Services/Auth/OauthLoginService.phpindex 761b6a8ccb..5915b0cd8a 100644--- a/app/Services/Auth/OauthLoginService.php+++ b/app/Services/Auth/OauthLoginService.php@@ -29,7 +29,7 @@ class OauthLoginService: $this->resolveOauthUser($oauthUser, $oauthSetting, $email);$team = $user->currentTeam() ?? $user->teams()->first() ?? $user->recreate_personal_team();- session(['currentTeam' => $user->currentTeam = $team]);+ session(['currentTeam' => $team]);if ($this->requiresTwoFactorChallenge($user)) {Auth::logout();