mirror of
https://github.com/coollabsio/coolify.git
synced 2026-09-28 02:06:37 -04:00
fix(team): resolve stored team on deletion and impersonation
Use resolveStoredTeam() instead of teams()->first() when picking the next active team after a team deletion or when an admin switches into a user's account, so a valid stored preference wins over an arbitrary first team. DeleteTeam now returns null when the deletion leaves the owner with multiple teams, deferring to the selection screen instead of guessing. refreshSession also stops persisting current_team_id while impersonating, so viewing another user's account no longer overwrites their real last-active team.
This commit is contained in:
committed by
Andras Bacsai
parent
f511921895
commit
e52390ec03
@@ -602,9 +602,11 @@ function refreshSession(?Team $team = null): void
|
||||
});
|
||||
session(['currentTeam' => $team]);
|
||||
|
||||
// Persist the active team so it can be restored after logout/login.
|
||||
// Persist the active team so it can be restored after logout/login — but
|
||||
// never while an admin is impersonating, so viewing another user's account
|
||||
// does not overwrite that user's real last-active team.
|
||||
$user = Auth::user();
|
||||
if ($user && $user->current_team_id !== $team->id) {
|
||||
if ($user && ! session('impersonating') && $user->current_team_id !== $team->id) {
|
||||
$user->current_team_id = $team->id;
|
||||
$user->saveQuietly();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user