Home sweet home (#3313)

* Link to store home, show home only if there is no store

* Handle store guest case

* Apply correct policies to nav items
This commit is contained in:
d11n
2022-01-18 02:20:59 +01:00
committed by GitHub
parent c3f73c0de3
commit 1d3f74c8bb
8 changed files with 74 additions and 37 deletions

View File

@@ -78,14 +78,23 @@ namespace BTCPayServer.Controllers
var storeId = HttpContext.GetUserPrefsCookie()?.CurrentStoreId;
if (storeId != null)
{
// verify store exists and redirect to it
var store = await _storeRepository.FindStore(storeId, userId);
if (store != null)
{
HttpContext.SetStoreData(store);
return store.Role == StoreRoles.Owner
? RedirectToAction("Dashboard", "UIStores", new { storeId })
: RedirectToAction("ListInvoices", "UIInvoice", new { storeId });
}
}
var stores = await _storeRepository.GetStoresByUserId(userId);
if (stores.Any())
{
// redirect to first store
storeId = stores.First().Id;
return RedirectToAction("Dashboard", "UIStores", new { storeId });
}
var vm = new HomeViewModel
{