diff --git a/BTCPayServer/Controllers/ServerController.cs b/BTCPayServer/Controllers/ServerController.cs new file mode 100644 index 000000000..b0bc1ce3b --- /dev/null +++ b/BTCPayServer/Controllers/ServerController.cs @@ -0,0 +1,34 @@ +using BTCPayServer.Models; +using BTCPayServer.Models.ServerViewModels; +using Microsoft.AspNetCore.Identity; +using Microsoft.AspNetCore.Mvc; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace BTCPayServer.Controllers +{ + public class ServerController : Controller + { + private UserManager _UserManager; + + public ServerController(UserManager userManager) + { + _UserManager = userManager; + } + + [Route("server/users")] + public IActionResult ListUsers() + { + var users = new UsersViewModel(); + users.Users + = _UserManager.Users.Select(u => new UsersViewModel.UserViewModel() + { + Name = u.UserName, + Email = u.Email + }).ToList(); + return View(users); + } + } +} diff --git a/BTCPayServer/Models/ServerViewModels/UsersViewModel.cs b/BTCPayServer/Models/ServerViewModels/UsersViewModel.cs new file mode 100644 index 000000000..f5cf2c2bb --- /dev/null +++ b/BTCPayServer/Models/ServerViewModels/UsersViewModel.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace BTCPayServer.Models.ServerViewModels +{ + public class UsersViewModel + { + public class UserViewModel + { + public string Name + { + get; set; + } + public string Email + { + get; set; + } + } + + public string StatusMessage + { + get; set; + } + + public List Users + { + get; set; + } = new List(); + } + +} diff --git a/BTCPayServer/Views/Manage/Disable2fa.cshtml b/BTCPayServer/Views/Manage/Disable2fa.cshtml index cdd79cb62..626d6308d 100644 --- a/BTCPayServer/Views/Manage/Disable2fa.cshtml +++ b/BTCPayServer/Views/Manage/Disable2fa.cshtml @@ -1,24 +1,26 @@ @{ - ViewData["Title"] = "Disable two-factor authentication (2FA)"; - ViewData.AddActivePage(ManageNavPages.TwoFactorAuthentication); + ViewData["Title"] = "Disable two-factor authentication (2FA)"; + ViewData.AddActivePage(ManageNavPages.TwoFactorAuthentication); }

@ViewData["Title"]

-
- -
+
+ +
diff --git a/BTCPayServer/Views/Manage/ExternalLogins.cshtml b/BTCPayServer/Views/Manage/ExternalLogins.cshtml index e6f568726..9a2f4e1f0 100644 --- a/BTCPayServer/Views/Manage/ExternalLogins.cshtml +++ b/BTCPayServer/Views/Manage/ExternalLogins.cshtml @@ -1,7 +1,7 @@ @model ExternalLoginsViewModel @{ - ViewData["Title"] = "Manage your external logins"; - ViewData.AddActivePage(ManageNavPages.ExternalLogins); + ViewData["Title"] = "Manage your external logins"; + ViewData.AddActivePage(ManageNavPages.ExternalLogins); } @Html.Partial("_StatusMessage", Model.StatusMessage) diff --git a/BTCPayServer/Views/Manage/GenerateRecoveryCodes.cshtml b/BTCPayServer/Views/Manage/GenerateRecoveryCodes.cshtml index 669d13ef9..3ed07d769 100644 --- a/BTCPayServer/Views/Manage/GenerateRecoveryCodes.cshtml +++ b/BTCPayServer/Views/Manage/GenerateRecoveryCodes.cshtml @@ -1,7 +1,7 @@ @model GenerateRecoveryCodesViewModel @{ - ViewData["Title"] = "Recovery codes"; - ViewData.AddActivePage(ManageNavPages.TwoFactorAuthentication); + ViewData["Title"] = "Recovery codes"; + ViewData.AddActivePage(ManageNavPages.TwoFactorAuthentication); }

@ViewData["Title"]

diff --git a/BTCPayServer/Views/Manage/ResetAuthenticator.cshtml b/BTCPayServer/Views/Manage/ResetAuthenticator.cshtml index 54a23613c..a1058bc50 100644 --- a/BTCPayServer/Views/Manage/ResetAuthenticator.cshtml +++ b/BTCPayServer/Views/Manage/ResetAuthenticator.cshtml @@ -1,6 +1,6 @@ @{ - ViewData["Title"] = "Reset authenticator key"; - ViewData.AddActivePage(ManageNavPages.TwoFactorAuthentication); + ViewData["Title"] = "Reset authenticator key"; + ViewData.AddActivePage(ManageNavPages.TwoFactorAuthentication); }

@ViewData["Title"]

diff --git a/BTCPayServer/Views/Manage/SetPassword.cshtml b/BTCPayServer/Views/Manage/SetPassword.cshtml index 56c359935..8600ef251 100644 --- a/BTCPayServer/Views/Manage/SetPassword.cshtml +++ b/BTCPayServer/Views/Manage/SetPassword.cshtml @@ -1,7 +1,7 @@ @model SetPasswordViewModel @{ - ViewData["Title"] = "Set password"; - ViewData.AddActivePage(ManageNavPages.ChangePassword); + ViewData["Title"] = "Set password"; + ViewData.AddActivePage(ManageNavPages.ChangePassword); }

Set your password

diff --git a/BTCPayServer/Views/Manage/TwoFactorAuthentication.cshtml b/BTCPayServer/Views/Manage/TwoFactorAuthentication.cshtml index a2b52ac5b..6cc151544 100644 --- a/BTCPayServer/Views/Manage/TwoFactorAuthentication.cshtml +++ b/BTCPayServer/Views/Manage/TwoFactorAuthentication.cshtml @@ -1,7 +1,7 @@ @model TwoFactorAuthenticationViewModel @{ - ViewData["Title"] = "Two-factor authentication"; - ViewData.AddActivePage(ManageNavPages.TwoFactorAuthentication); + ViewData["Title"] = "Two-factor authentication"; + ViewData.AddActivePage(ManageNavPages.TwoFactorAuthentication); }

@ViewData["Title"]

diff --git a/BTCPayServer/Views/Manage/_Layout.cshtml b/BTCPayServer/Views/Manage/_Layout.cshtml deleted file mode 100644 index d83de1c64..000000000 --- a/BTCPayServer/Views/Manage/_Layout.cshtml +++ /dev/null @@ -1,30 +0,0 @@ -@{ - Layout = "/Views/Shared/_Layout.cshtml"; -} - - -
-
-
-
-

Manage your account

-
-
-
- -
-
-
- @await Html.PartialAsync("_ManageNav") -
-
- @RenderBody() -
-
-
-
-
-@section Scripts { - @RenderSection("Scripts", required: false) -} - diff --git a/BTCPayServer/Views/Manage/_ManageNav.cshtml b/BTCPayServer/Views/Manage/_Nav.cshtml similarity index 100% rename from BTCPayServer/Views/Manage/_ManageNav.cshtml rename to BTCPayServer/Views/Manage/_Nav.cshtml diff --git a/BTCPayServer/Views/Manage/_ViewStart.cshtml b/BTCPayServer/Views/Manage/_ViewStart.cshtml new file mode 100644 index 000000000..cfbc8ce0e --- /dev/null +++ b/BTCPayServer/Views/Manage/_ViewStart.cshtml @@ -0,0 +1,4 @@ +@{ + Layout = "../Shared/_NavLayout.cshtml"; + ViewBag.MainTitle = "Manage your account"; +} diff --git a/BTCPayServer/Views/Server/ListUsers.cshtml b/BTCPayServer/Views/Server/ListUsers.cshtml new file mode 100644 index 000000000..0a357cf9e --- /dev/null +++ b/BTCPayServer/Views/Server/ListUsers.cshtml @@ -0,0 +1,28 @@ +@model UsersViewModel +@{ + ViewData["Title"] = "Users"; + ViewData.AddActivePage(ServerNavPages.Users); +} + + +

@ViewData["Title"]

+@Html.Partial("_StatusMessage", Model.StatusMessage) + + + + + + + + + + + @foreach(var user in Model.Users) + { + + + + + } + +
NameEmail
@user.Name@user.Email
\ No newline at end of file diff --git a/BTCPayServer/Views/Server/ServerNavPages.cs b/BTCPayServer/Views/Server/ServerNavPages.cs new file mode 100644 index 000000000..9885451fa --- /dev/null +++ b/BTCPayServer/Views/Server/ServerNavPages.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc.Rendering; +using Microsoft.AspNetCore.Mvc.ViewFeatures; + +namespace BTCPayServer.Views.Server +{ + public static class ServerNavPages + { + public static string ActivePageKey => "ActivePage"; + public static string Index => "Index"; + + + public static string Users => "Users"; + + public static string UsersNavClass(ViewContext viewContext) => PageNavClass(viewContext, Users); + + public static string IndexNavClass(ViewContext viewContext) => PageNavClass(viewContext, Index); + + public static string PageNavClass(ViewContext viewContext, string page) + { + var activePage = viewContext.ViewData["ActivePage"] as string; + return string.Equals(activePage, page, StringComparison.OrdinalIgnoreCase) ? "active" : null; + } + + public static void AddActivePage(this ViewDataDictionary viewData, string activePage) => viewData[ActivePageKey] = activePage; + } +} diff --git a/BTCPayServer/Views/Server/_Nav.cshtml b/BTCPayServer/Views/Server/_Nav.cshtml new file mode 100644 index 000000000..4bb1ea3af --- /dev/null +++ b/BTCPayServer/Views/Server/_Nav.cshtml @@ -0,0 +1,6 @@ +@using BTCPayServer.Views.Server + + + diff --git a/BTCPayServer/Views/Server/_ViewImports.cshtml b/BTCPayServer/Views/Server/_ViewImports.cshtml new file mode 100644 index 000000000..85eec8f2d --- /dev/null +++ b/BTCPayServer/Views/Server/_ViewImports.cshtml @@ -0,0 +1,2 @@ +@using BTCPayServer.Views.Server +@using BTCPayServer.Models.ServerViewModels diff --git a/BTCPayServer/Views/Server/_ViewStart.cshtml b/BTCPayServer/Views/Server/_ViewStart.cshtml new file mode 100644 index 000000000..adb8c2e52 --- /dev/null +++ b/BTCPayServer/Views/Server/_ViewStart.cshtml @@ -0,0 +1,4 @@ +@{ + Layout = "../Shared/_NavLayout.cshtml"; + ViewBag.MainTitle = "Server settings"; +} diff --git a/BTCPayServer/Views/Shared/_Layout.cshtml b/BTCPayServer/Views/Shared/_Layout.cshtml index e1ac737c2..d8705ee56 100644 --- a/BTCPayServer/Views/Shared/_Layout.cshtml +++ b/BTCPayServer/Views/Shared/_Layout.cshtml @@ -53,7 +53,7 @@ { @if(User.IsInRole(Roles.ServerAdmin)) { - + } diff --git a/BTCPayServer/Views/Stores/_Layout.cshtml b/BTCPayServer/Views/Shared/_NavLayout.cshtml similarity index 81% rename from BTCPayServer/Views/Stores/_Layout.cshtml rename to BTCPayServer/Views/Shared/_NavLayout.cshtml index 200f996a6..49e110329 100644 --- a/BTCPayServer/Views/Stores/_Layout.cshtml +++ b/BTCPayServer/Views/Shared/_NavLayout.cshtml @@ -7,7 +7,7 @@
-

Manage your store

+

@ViewData["MainTitle"]


@@ -15,7 +15,7 @@
- @await Html.PartialAsync("_StoreNav") + @await Html.PartialAsync("_Nav")
@RenderBody() diff --git a/BTCPayServer/Views/Stores/CreateStore.cshtml b/BTCPayServer/Views/Stores/CreateStore.cshtml index 7b706ba76..c2f774aa0 100644 --- a/BTCPayServer/Views/Stores/CreateStore.cshtml +++ b/BTCPayServer/Views/Stores/CreateStore.cshtml @@ -1,6 +1,5 @@ @model BTCPayServer.Models.StoreViewModels.CreateStoreViewModel @{ - Layout = "/Views/Shared/_Layout.cshtml"; ViewData["Title"] = "Create a new store"; }
diff --git a/BTCPayServer/Views/Stores/CreateToken.cshtml b/BTCPayServer/Views/Stores/CreateToken.cshtml index fbced742c..aad53a295 100644 --- a/BTCPayServer/Views/Stores/CreateToken.cshtml +++ b/BTCPayServer/Views/Stores/CreateToken.cshtml @@ -1,5 +1,6 @@ @model CreateTokenViewModel @{ + Layout = "../Shared/_NavLayout.cshtml"; ViewData["Title"] = "Create a new token"; ViewData.AddActivePage(StoreNavPages.Tokens); } diff --git a/BTCPayServer/Views/Stores/ListStores.cshtml b/BTCPayServer/Views/Stores/ListStores.cshtml index 89f073bf5..a56d74657 100644 --- a/BTCPayServer/Views/Stores/ListStores.cshtml +++ b/BTCPayServer/Views/Stores/ListStores.cshtml @@ -1,6 +1,5 @@ @model StoresViewModel @{ - Layout = "/Views/Shared/_Layout.cshtml"; ViewData["Title"] = "Stores"; } diff --git a/BTCPayServer/Views/Stores/ListTokens.cshtml b/BTCPayServer/Views/Stores/ListTokens.cshtml index 316ce42bd..a230fb313 100644 --- a/BTCPayServer/Views/Stores/ListTokens.cshtml +++ b/BTCPayServer/Views/Stores/ListTokens.cshtml @@ -1,5 +1,6 @@ @model TokensViewModel @{ + Layout = "../Shared/_NavLayout.cshtml"; ViewData["Title"] = "Access Tokens"; ViewData.AddActivePage(StoreNavPages.Tokens); } diff --git a/BTCPayServer/Views/Stores/RequestPairing.cshtml b/BTCPayServer/Views/Stores/RequestPairing.cshtml index b708253dc..d387386e3 100644 --- a/BTCPayServer/Views/Stores/RequestPairing.cshtml +++ b/BTCPayServer/Views/Stores/RequestPairing.cshtml @@ -1,6 +1,5 @@ @model PairingModel @{ - Layout = "/Views/Shared/_Layout.cshtml"; ViewData["Title"] = "Pairing permission"; } diff --git a/BTCPayServer/Views/Stores/UpdateStore.cshtml b/BTCPayServer/Views/Stores/UpdateStore.cshtml index 041ebbee4..b89188809 100644 --- a/BTCPayServer/Views/Stores/UpdateStore.cshtml +++ b/BTCPayServer/Views/Stores/UpdateStore.cshtml @@ -1,5 +1,6 @@ @model StoreViewModel @{ + Layout = "../Shared/_NavLayout.cshtml"; ViewData["Title"] = "Profile"; ViewData.AddActivePage(BTCPayServer.Views.Stores.StoreNavPages.Index); } diff --git a/BTCPayServer/Views/Stores/_StoreNav.cshtml b/BTCPayServer/Views/Stores/_Nav.cshtml similarity index 77% rename from BTCPayServer/Views/Stores/_StoreNav.cshtml rename to BTCPayServer/Views/Stores/_Nav.cshtml index 41998d07c..da0c96a1f 100644 --- a/BTCPayServer/Views/Stores/_StoreNav.cshtml +++ b/BTCPayServer/Views/Stores/_Nav.cshtml @@ -1,8 +1,5 @@ @using BTCPayServer.Views.Stores @inject SignInManager SignInManager -@{ - var hasExternalLogins = (await SignInManager.GetExternalAuthenticationSchemesAsync()).Any(); -}