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): preserve invite login with database sessions
Andras Bacsaic0866d4cb33e
diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.phpindex a567c62449..c723d811a4 100644--- a/app/Http/Controllers/Controller.php+++ b/app/Http/Controllers/Controller.php@@ -138,10 +138,11 @@ class Controller extends BaseController}$invitation->delete();- Auth::login($user);$user->forceFill(['password' => Hash::make(Str::random(64)),])->save();++ Auth::login($user);session(['currentTeam' => $team]);return redirect()->route('dashboard');diff --git a/tests/Feature/InvitationLinkHandlingTest.php b/tests/Feature/InvitationLinkHandlingTest.phpindex 184dfd77fe..3b473f60e4 100644--- a/tests/Feature/InvitationLinkHandlingTest.php+++ b/tests/Feature/InvitationLinkHandlingTest.php@@ -9,6 +9,7 @@ use App\Models\User;use Illuminate\Foundation\Testing\RefreshDatabase;use Illuminate\Support\Facades\Config;use Illuminate\Support\Facades\Crypt;+use Illuminate\Support\Facades\DB;use Illuminate\Support\Facades\Hash;use Illuminate\Support\Once;use Visus\Cuid2\Cuid2;@@ -91,6 +92,27 @@ it('accepts a magic link when opened from a different public origin', function (expect(Hash::check($password, $user->password))->toBeFalse();});+it('keeps the invited user authenticated after rotating the temporary password with database sessions', function () {+ $this->withMiddleware([CheckForcePasswordReset::class, DecideWhatToDoWithUser::class]);+ Config::set('session.driver', 'database');++ [$team, $user, $password, $token] = createInvitationLinkFixture();++ $this->get(route('auth.link', ['token' => $token]))+ ->assertRedirect(route('dashboard'));++ expect(DB::table('sessions')->where('user_id', $user->id)->exists())->toBeTrue();++ $this->get(route('dashboard'))+ ->assertRedirect(route('auth.force-password-reset'));++ $this->assertAuthenticatedAs($user);+ expect($user->teams()->where('team_id', $team->id)->exists())->toBeTrue();++ $user->refresh();+ expect(Hash::check($password, $user->password))->toBeFalse();+});+it('rejects a magic link when the stored invitation token differs', function () {[, $user, , $token, $invitation] = createInvitationLinkFixture();$differentToken = Crypt::encryptString("{$user->email}@@@{$invitation->uuid}@@@different-password");