diff --git a/BTCPayServer/Blazor/PosLoginCode.razor b/BTCPayServer/Blazor/PosLoginCode.razor index bfd7c59b0..603832593 100644 --- a/BTCPayServer/Blazor/PosLoginCode.razor +++ b/BTCPayServer/Blazor/PosLoginCode.razor @@ -2,7 +2,7 @@ {
- @foreach (var u in Users) { @@ -18,20 +18,56 @@ } else { - + @if (IsSelectedUserOwner() && !_ownerConfirmed) + { +
+

This user is Store Owner

+

Please confirm you want this QR code to be displayed.

+ + +
+ } + else + { + + } } @code { - [Parameter, EditorRequired] - public string PosPath { get; set; } + [Parameter, EditorRequired] public string PosPath { get; set; } - [Parameter] - public Dictionary Users { get; set; } + [Parameter] public Dictionary Users { get; set; } [Parameter] public string PosUrl { get; set; } [Parameter(CaptureUnmatchedValues = true)] public Dictionary Attrs { get; set; } private string _userId; + private bool _ownerConfirmed = false; private string CssClass => $"form-group {(Attrs?.ContainsKey("class") is true ? Attrs["class"] : "")}".Trim(); + + private void OnUserChanged(ChangeEventArgs e) + { + _userId = e.Value?.ToString(); + _ownerConfirmed = false; // Reset confirmation when user changes + } + + private bool IsSelectedUserOwner() + { + if (string.IsNullOrEmpty(_userId) || Users == null) + return false; + + if (Users.TryGetValue(_userId, out var userInfo)) + { + return userInfo.Contains("Owner", StringComparison.OrdinalIgnoreCase); + } + + return false; + } + + private void ConfirmOwnerDisplay() + { + _ownerConfirmed = true; + } + } diff --git a/BTCPayServer/Plugins/PointOfSale/Controllers/UIPointOfSaleController.cs b/BTCPayServer/Plugins/PointOfSale/Controllers/UIPointOfSaleController.cs index 3e9c5e8f5..4d6cfd472 100644 --- a/BTCPayServer/Plugins/PointOfSale/Controllers/UIPointOfSaleController.cs +++ b/BTCPayServer/Plugins/PointOfSale/Controllers/UIPointOfSaleController.cs @@ -708,7 +708,12 @@ namespace BTCPayServer.Plugins.PointOfSale.Controllers private async Task FillUsers(UpdatePointOfSaleViewModel vm) { var users = await _storeRepository.GetStoreUsers(GetCurrentStore().Id); - vm.StoreUsers = users.Where(u => u.Id == _userManager.GetUserId(User)).Select(u => (u.Id, u.Email, u.StoreRole.Role)).ToDictionary(u => u.Id, u => $"{u.Email} ({u.Role})"); + + if (!User.IsInRole(Roles.ServerAdmin)) + users = users.Where(u => u.Id == _userManager.GetUserId(User)).ToArray(); + + vm.StoreUsers = users.Select(u => (u.Id, u.Email, u.StoreRole.Role)) + .ToDictionary(u => u.Id, u => $"{u.Email} ({u.Role})"); } } }