From 470228624dd525cd801cf5faac007acedbb123fe Mon Sep 17 00:00:00 2001 From: Pat Hartl Date: Sun, 22 Jan 2023 22:46:02 -0600 Subject: [PATCH] Only allocate a key belonging to the game --- LANCommander/Controllers/Api/KeysController.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/LANCommander/Controllers/Api/KeysController.cs b/LANCommander/Controllers/Api/KeysController.cs index 36d44fd..ab3ad97 100644 --- a/LANCommander/Controllers/Api/KeysController.cs +++ b/LANCommander/Controllers/Api/KeysController.cs @@ -34,7 +34,8 @@ namespace LANCommander.Controllers.Api if (existing != null) await KeyService.Release(existing.Id); - var availableKey = KeyService.Get(k => + var availableKey = KeyService.Get(k => k.Game.Id == id) + .Where(k => (k.AllocationMethod == Data.Models.KeyAllocationMethod.MacAddress && String.IsNullOrWhiteSpace(k.ClaimedByMacAddress)) || (k.AllocationMethod == Data.Models.KeyAllocationMethod.UserAccount && k.ClaimedByUser == null))