Fix new guest store redirect after login

Fixes #3373.
This commit is contained in:
Dennis Reimann 2022-01-28 09:36:48 +01:00 committed by Andrew Camilleri
parent f776725096
commit 52fe374aaa

View file

@ -82,9 +82,7 @@ namespace BTCPayServer.Controllers
var store = await _storeRepository.FindStore(storeId, userId); var store = await _storeRepository.FindStore(storeId, userId);
if (store != null) if (store != null)
{ {
return store.Role == StoreRoles.Owner return RedirectToStore(store);
? RedirectToAction("Dashboard", "UIStores", new { storeId })
: RedirectToAction("ListInvoices", "UIInvoice", new { storeId });
} }
} }
@ -92,8 +90,7 @@ namespace BTCPayServer.Controllers
if (stores.Any()) if (stores.Any())
{ {
// redirect to first store // redirect to first store
storeId = stores.First().Id; return RedirectToStore(stores.First());
return RedirectToAction("Dashboard", "UIStores", new { storeId });
} }
var vm = new HomeViewModel var vm = new HomeViewModel
@ -169,5 +166,12 @@ namespace BTCPayServer.Controllers
{ {
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
} }
public RedirectToActionResult RedirectToStore(StoreData store)
{
return store.Role == StoreRoles.Owner
? RedirectToAction("Dashboard", "UIStores", new { storeId = store.Id })
: RedirectToAction("ListInvoices", "UIInvoice", new { storeId = store.Id });
}
} }
} }