diff --git a/Server/src/SOR.Admin/Components/Pages/Bazaar/PrebuiltDeckEditor.razor b/Server/src/SOR.Admin/Components/Pages/Bazaar/PrebuiltDeckEditor.razor
index 183b54d..8816f6e 100644
--- a/Server/src/SOR.Admin/Components/Pages/Bazaar/PrebuiltDeckEditor.razor
+++ b/Server/src/SOR.Admin/Components/Pages/Bazaar/PrebuiltDeckEditor.razor
@@ -294,8 +294,9 @@ else
private async Task SearchCardsAsync()
{
if (string.IsNullOrWhiteSpace(_cardSearch)) return;
+ var term = _cardSearch.Trim();
_cardResults = await CatalogDb.CardDefinitions
- .Where(c => c.Name.Contains(_cardSearch))
+ .Where(c => EF.Functions.ILike(c.Name, $"%{term}%"))
.OrderBy(c => c.Name)
.Take(10)
.ToListAsync();
@@ -304,8 +305,9 @@ else
private async Task SearchArchSpiritsAsync()
{
if (string.IsNullOrWhiteSpace(_archSearch)) return;
+ var term = _archSearch.Trim();
_archResults = await CatalogDb.CardDefinitions
- .Where(c => c.CardType == CardType.ArchSpirit && c.Name.Contains(_archSearch))
+ .Where(c => c.CardType == CardType.ArchSpirit && EF.Functions.ILike(c.Name, $"%{term}%"))
.OrderBy(c => c.Name)
.Take(10)
.ToListAsync();
diff --git a/Server/src/SOR.Auth/Handlers/AuthGrpcHandler.cs b/Server/src/SOR.Auth/Handlers/AuthGrpcHandler.cs
index 7297334..fc58d87 100644
--- a/Server/src/SOR.Auth/Handlers/AuthGrpcHandler.cs
+++ b/Server/src/SOR.Auth/Handlers/AuthGrpcHandler.cs
@@ -72,6 +72,11 @@ public sealed class AuthGrpcHandler : AuthService.AuthServiceBase
user.LastLoginAt = DateTimeOffset.UtcNow;
await _userManager.UpdateAsync(user);
+ // Single-session policy: revoke all active sessions before issuing a new one.
+ // This ensures only one device is logged in at a time. The old device will
+ // receive an auth failure on its next auth.hello and return to the login screen.
+ await RevokeAllSessionsForUserAsync(user.Id);
+
var token = await CreateSessionAsync(user.Id, context);
_logger.LogInformation("Login succeeded for account {AccountId}", user.Id);
return new LoginResponse
@@ -348,6 +353,37 @@ public sealed class AuthGrpcHandler : AuthService.AuthServiceBase
// ── Helpers ───────────────────────────────────────────────────────────────
+ ///
+ /// Revokes all active sessions for the given account in both Redis and Postgres.
+ /// Called before issuing a new session token so only one device is ever logged in.
+ ///
+ private async Task RevokeAllSessionsForUserAsync(Guid accountId)
+ {
+ var now = DateTimeOffset.UtcNow;
+ var cache = _redis.GetDatabase();
+ var userKey = RedisKeys.UserSessions(accountId.ToString());
+
+ var members = await cache.SetMembersAsync(userKey);
+ foreach (var member in members)
+ await cache.KeyDeleteAsync(RedisKeys.Session(member!));
+ await cache.KeyDeleteAsync(userKey);
+
+ var sessions = await _db.AccountSessions
+ .Where(s => s.AccountId == accountId && s.RevokedAt == null && s.ExpiresAt > now)
+ .ToListAsync();
+
+ foreach (var s in sessions)
+ s.RevokedAt = now;
+
+ if (sessions.Count > 0)
+ {
+ await _db.SaveChangesAsync();
+ _logger.LogInformation(
+ "Revoked {Count} existing session(s) for account {AccountId} on new login",
+ sessions.Count, accountId);
+ }
+ }
+
///
/// Generates a cryptographically random session token, persists the hash to Postgres,
/// and caches the raw token → accountId mapping in Redis.