mirror of
https://github.com/coollabsio/coolify.git
synced 2026-09-28 02:06:37 -04:00
fix(teams): clear stale current_team_id when membership ends
Reset the user's persisted current_team_id when they are removed from a team, when their team is deleted, or when refreshSession finds no team left, so a dangling reference is never restored on next login.
This commit is contained in:
committed by
Andras Bacsai
parent
12498b4b86
commit
2b92fb86b5
@@ -581,8 +581,13 @@ function refreshSession(?Team $team = null): void
|
||||
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.
|
||||
// dereferencing null, and drop the persisted choice so it is not
|
||||
// restored on next login.
|
||||
session()->forget('currentTeam');
|
||||
$user = Auth::user();
|
||||
if ($user && ! is_null($user->current_team_id)) {
|
||||
$user->forceFill(['current_team_id' => null])->saveQuietly();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user