mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2026-01-03 22:24:27 +01:00
Admin overview of the stores on the instance (#5745)
* Admin overview of the stores on the instance POC/Draft for #5674. * Enable admin to access foreign stores * Remove stores list link * UI updates * Grant admins guest access to foreign stores * Optimize cookie auth handler * Test fix * Revert changes related to StoreRepository.FindStore with isAdmin
This commit is contained in:
@@ -52,6 +52,8 @@ namespace BTCPayServer.Controllers
|
||||
model.Roles = roleManager.Roles.ToDictionary(role => role.Id, role => role.Name);
|
||||
model.Users = await usersQuery
|
||||
.Include(user => user.UserRoles)
|
||||
.Include(user => user.UserStores)
|
||||
.ThenInclude(data => data.StoreData)
|
||||
.Skip(model.Skip)
|
||||
.Take(model.Count)
|
||||
.Select(u => new UsersViewModel.UserViewModel
|
||||
@@ -63,7 +65,8 @@ namespace BTCPayServer.Controllers
|
||||
Approved = u.RequiresApproval ? u.Approved : null,
|
||||
Created = u.Created,
|
||||
Roles = u.UserRoles.Select(role => role.RoleId),
|
||||
Disabled = u.LockoutEnabled && u.LockoutEnd != null && DateTimeOffset.UtcNow < u.LockoutEnd.Value.UtcDateTime
|
||||
Disabled = u.LockoutEnabled && u.LockoutEnd != null && DateTimeOffset.UtcNow < u.LockoutEnd.Value.UtcDateTime,
|
||||
Stores = u.UserStores.OrderBy(s => !s.StoreData.Archived).ToList()
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ using BTCPayServer.Hosting;
|
||||
using BTCPayServer.Logging;
|
||||
using BTCPayServer.Models;
|
||||
using BTCPayServer.Models.ServerViewModels;
|
||||
using BTCPayServer.Models.StoreViewModels;
|
||||
using BTCPayServer.Payments;
|
||||
using BTCPayServer.Services;
|
||||
using BTCPayServer.Services.Apps;
|
||||
@@ -122,6 +123,26 @@ namespace BTCPayServer.Controllers
|
||||
_transactionLinkProviders = transactionLinkProviders;
|
||||
}
|
||||
|
||||
[HttpGet("server/stores")]
|
||||
public async Task<IActionResult> ListStores()
|
||||
{
|
||||
var stores = await _StoreRepository.GetStores();
|
||||
var vm = new ListStoresViewModel
|
||||
{
|
||||
Stores = stores
|
||||
.Select(s => new ListStoresViewModel.StoreViewModel
|
||||
{
|
||||
StoreId = s.Id,
|
||||
StoreName = s.StoreName,
|
||||
Archived = s.Archived,
|
||||
Users = s.UserStores
|
||||
})
|
||||
.OrderBy(s => !s.Archived)
|
||||
.ToList()
|
||||
};
|
||||
return View(vm);
|
||||
}
|
||||
|
||||
[HttpGet("server/maintenance")]
|
||||
public IActionResult Maintenance()
|
||||
{
|
||||
|
||||
@@ -150,6 +150,7 @@ namespace BTCPayServer.Controllers
|
||||
{
|
||||
return Forbid();
|
||||
}
|
||||
HttpContext.SetStoreData(store);
|
||||
if (store.GetPermissionSet(userId).Contains(Policies.CanModifyStoreSettings, storeId))
|
||||
{
|
||||
return RedirectToAction("Dashboard", new { storeId });
|
||||
@@ -158,7 +159,6 @@ namespace BTCPayServer.Controllers
|
||||
{
|
||||
return RedirectToAction("ListInvoices", "UIInvoice", new { storeId });
|
||||
}
|
||||
HttpContext.SetStoreData(store);
|
||||
return View();
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace BTCPayServer.Controllers
|
||||
_rateFactory = rateFactory;
|
||||
}
|
||||
|
||||
[HttpGet()]
|
||||
[HttpGet]
|
||||
[Authorize(AuthenticationSchemes = AuthenticationSchemes.Cookie, Policy = Policies.CanModifyStoreSettingsUnscoped)]
|
||||
public async Task<IActionResult> ListStores(bool archived = false)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user