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
feat(auth): enhance user login flow to handle team invitations, attaching users to invited teams upon first login and maintaining personal team logic for regular logins
Andras Bacsaia1eaa046c9f4
diff --git a/app/Providers/FortifyServiceProvider.php b/app/Providers/FortifyServiceProvider.phpindex ed27a158a1..30d9093882 100644--- a/app/Providers/FortifyServiceProvider.php+++ b/app/Providers/FortifyServiceProvider.php@@ -80,9 +80,23 @@ class FortifyServiceProvider extends ServiceProvider) {$user->updated_at = now();$user->save();- $user->currentTeam = $user->teams->firstWhere('personal_team', true);- if (! $user->currentTeam) {- $user->currentTeam = $user->recreate_personal_team();++ // Check if user has a pending invitation they haven't accepted yet+ $invitation = \App\Models\TeamInvitation::whereEmail($email)->first();+ if ($invitation && $invitation->isValid()) {+ // User is logging in for the first time after being invited+ // Attach them to the invited team if not already attached+ if (! $user->teams()->where('team_id', $invitation->team->id)->exists()) {+ $user->teams()->attach($invitation->team->id, ['role' => $invitation->role]);+ }+ $user->currentTeam = $invitation->team;+ $invitation->delete();+ } else {+ // Normal login - use personal team+ $user->currentTeam = $user->teams->firstWhere('personal_team', true);+ if (! $user->currentTeam) {+ $user->currentTeam = $user->recreate_personal_team();+ }}session(['currentTeam' => $user->currentTeam]);