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))) {