fix(user): improve cache key and remove redundant route check
- Include sessionTeamId in currentTeam() cache key to prevent stale
team data when users switch teams
- Update refreshSession() to use new cache key format
- Remove redundant routeIs('settings.index') check since settings.*
already matches it
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
2743229cc4
commit
ddd78658e8
3 changed files with 6 additions and 3 deletions
|
|
@ -27,7 +27,7 @@ public function handle(Request $request, Closure $next): Response
|
|||
return $next($request);
|
||||
}
|
||||
// Instance admins can access settings and admin routes regardless of subscription
|
||||
if (isInstanceAdmin() && ($request->routeIs('settings.*') || $request->routeIs('settings.index') || $request->path() === 'admin')) {
|
||||
if (isInstanceAdmin() && ($request->routeIs('settings.*') || $request->path() === 'admin')) {
|
||||
return $next($request);
|
||||
}
|
||||
if (! auth()->user()->hasVerifiedEmail()) {
|
||||
|
|
|
|||
|
|
@ -319,7 +319,7 @@ public function currentTeam(): ?Team
|
|||
return null;
|
||||
}
|
||||
|
||||
return Cache::remember('team:'.$this->id, 3600, function () use ($sessionTeamId) {
|
||||
return Cache::remember('user:'.$this->id.':team:'.$sessionTeamId, 3600, function () use ($sessionTeamId) {
|
||||
return Team::find($sessionTeamId);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -182,8 +182,11 @@ function refreshSession(?Team $team = null): void
|
|||
$team = User::find(Auth::id())->teams->first();
|
||||
}
|
||||
}
|
||||
// Clear old cache key format for backwards compatibility
|
||||
Cache::forget('team:'.Auth::id());
|
||||
Cache::remember('team:'.Auth::id(), 3600, function () use ($team) {
|
||||
// Use new cache key format that includes team ID
|
||||
Cache::forget('user:'.Auth::id().':team:'.$team->id);
|
||||
Cache::remember('user:'.Auth::id().':team:'.$team->id, 3600, function () use ($team) {
|
||||
return $team;
|
||||
});
|
||||
session(['currentTeam' => $team]);
|
||||
|
|
|
|||
Loading…
Reference in a new issue