From 82675384c42b99365d99de45ffca22a99fd84b82 Mon Sep 17 00:00:00 2001 From: Umar Bolatov Date: Sun, 19 Sep 2021 16:19:14 -0700 Subject: [PATCH] Don't adjust store mode if user is performing an action --- BTCPayServer/Controllers/ManageController.APIKeys.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/BTCPayServer/Controllers/ManageController.APIKeys.cs b/BTCPayServer/Controllers/ManageController.APIKeys.cs index deb6af70e..d1453806d 100644 --- a/BTCPayServer/Controllers/ManageController.APIKeys.cs +++ b/BTCPayServer/Controllers/ManageController.APIKeys.cs @@ -228,6 +228,14 @@ namespace BTCPayServer.Controllers } else if (wanted?.Any() ?? false) { + var commandParts = vm.Command?.Split(':', StringSplitOptions.RemoveEmptyEntries) ?? Array.Empty(); + var command = commandParts.Length > 1 ? commandParts[1] : null; + var isPerformingAnAction = command == "change-store-mode" || command == "add-store"; + // Don't want to accidentally change mode for the user if they are explicitly performing some action + if (isPerformingAnAction) { + continue; + } + if (vm.SelectiveStores && Policies.IsStorePolicy(permissionValue.Permission) && wanted.Any(permission => !string.IsNullOrEmpty(permission.Scope))) {