diff --git a/BTCPayServer/Controllers/UIServerController.Roles.cs b/BTCPayServer/Controllers/UIServerController.Roles.cs
index c65443d18..04bcfd699 100644
--- a/BTCPayServer/Controllers/UIServerController.Roles.cs
+++ b/BTCPayServer/Controllers/UIServerController.Roles.cs
@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;
-using Amazon.S3.Transfer;
using BTCPayServer.Abstractions.Constants;
using BTCPayServer.Abstractions.Extensions;
using BTCPayServer.Abstractions.Models;
@@ -167,9 +166,17 @@ namespace BTCPayServer.Controllers
[FromServices] StoreRepository storeRepository,
string role)
{
- await storeRepository.SetDefaultRole(role);
-
- TempData[WellKnownTempData.SuccessMessage] = "Role set default";
+ var resolved = await storeRepository.ResolveStoreRoleId(null, role);
+ if (resolved is null)
+ {
+ TempData[WellKnownTempData.ErrorMessage] = "Role could not be set as default";
+ }
+ else
+ {
+
+ await storeRepository.SetDefaultRole(role);
+ TempData[WellKnownTempData.SuccessMessage] = "Role set default";
+ }
return RedirectToAction(nameof(ListRoles));
}
diff --git a/BTCPayServer/Hosting/MigrationStartupTask.cs b/BTCPayServer/Hosting/MigrationStartupTask.cs
index 700a67b7d..77f4f8e79 100644
--- a/BTCPayServer/Hosting/MigrationStartupTask.cs
+++ b/BTCPayServer/Hosting/MigrationStartupTask.cs
@@ -111,12 +111,6 @@ namespace BTCPayServer.Hosting
settings.DeprecatedLightningConnectionStringCheck = true;
await _Settings.UpdateSetting(settings);
}
- if (!settings.UnreachableStoreCheck)
- {
- await UnreachableStoreCheck();
- settings.UnreachableStoreCheck = true;
- await _Settings.UpdateSetting(settings);
- }
if (!settings.ConvertMultiplierToSpread)
{
await ConvertMultiplierToSpread();
@@ -1068,11 +1062,6 @@ retry:
}
}
- private Task UnreachableStoreCheck()
- {
- return _StoreRepository.CleanUnreachableStores();
- }
-
private async Task DeprecatedLightningConnectionStringCheck()
{
using var ctx = _DBContextFactory.CreateContext();
diff --git a/BTCPayServer/Services/MigrationSettings.cs b/BTCPayServer/Services/MigrationSettings.cs
index 97c26306c..ebf987b74 100644
--- a/BTCPayServer/Services/MigrationSettings.cs
+++ b/BTCPayServer/Services/MigrationSettings.cs
@@ -7,7 +7,6 @@ namespace BTCPayServer.Services
[JsonProperty("MigrateHotwalletProperty2")]
public bool MigrateHotwalletProperty { get; set; }
public bool MigrateU2FToFIDO2 { get; set; }
- public bool UnreachableStoreCheck { get; set; }
public bool DeprecatedLightningConnectionStringCheck { get; set; }
public bool ConvertMultiplierToSpread { get; set; }
public bool ConvertNetworkFeeProperty { get; set; }
diff --git a/BTCPayServer/Services/Stores/StoreRepository.cs b/BTCPayServer/Services/Stores/StoreRepository.cs
index 73a4a3971..43249bf42 100644
--- a/BTCPayServer/Services/Stores/StoreRepository.cs
+++ b/BTCPayServer/Services/Stores/StoreRepository.cs
@@ -3,6 +3,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
+using Amazon.S3;
using BTCPayServer.Abstractions.Contracts;
using BTCPayServer.Client;
using BTCPayServer.Data;
@@ -229,18 +230,19 @@ namespace BTCPayServer.Services.Stores
///
///
///
- public async Task ResolveStoreRoleId(string storeId, string? role)
+ public async Task ResolveStoreRoleId(string? storeId, string? role)
{
if (string.IsNullOrWhiteSpace(role))
return null;
- var isStoreRole = role.Contains("::", StringComparison.OrdinalIgnoreCase);
- if(isStoreRole && (string.IsNullOrEmpty(storeId) || !role.Contains(storeId, StringComparison.InvariantCultureIgnoreCase)))
+ if (storeId?.Contains("::", StringComparison.OrdinalIgnoreCase) is true)
return null;
var roleId = StoreRoleId.Parse(role);
if (roleId.StoreId != null && roleId.StoreId != storeId)
return null;
if ((await GetStoreRole(roleId)) != null)
return roleId;
+ if (string.IsNullOrEmpty(storeId))
+ return null;
if (roleId.IsServerRole)
roleId = new StoreRoleId(storeId, role);
if ((await GetStoreRole(roleId)) != null)
diff --git a/BTCPayServer/Services/UserService.cs b/BTCPayServer/Services/UserService.cs
index c9cf5d6ab..1fcf725af 100644
--- a/BTCPayServer/Services/UserService.cs
+++ b/BTCPayServer/Services/UserService.cs
@@ -157,8 +157,6 @@ namespace BTCPayServer.Services
{
_logger.LogError($"Failed to delete user {user.Id}");
}
-
- await _storeRepository.CleanUnreachableStores();
}