mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-03-03 17:36:59 +01:00
Refactor nav pages, add page to see users of the server
This commit is contained in:
parent
6240abbb7b
commit
eb9f669224
26 changed files with 176 additions and 63 deletions
34
BTCPayServer/Controllers/ServerController.cs
Normal file
34
BTCPayServer/Controllers/ServerController.cs
Normal file
|
@ -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<ApplicationUser> _UserManager;
|
||||
|
||||
public ServerController(UserManager<ApplicationUser> 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);
|
||||
}
|
||||
}
|
||||
}
|
33
BTCPayServer/Models/ServerViewModels/UsersViewModel.cs
Normal file
33
BTCPayServer/Models/ServerViewModels/UsersViewModel.cs
Normal file
|
@ -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<UserViewModel> Users
|
||||
{
|
||||
get; set;
|
||||
} = new List<UserViewModel>();
|
||||
}
|
||||
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
||||
<h2>@ViewData["Title"]</h2>
|
||||
|
||||
<div class="alert alert-warning" role="alert">
|
||||
<p>
|
||||
<span class="glyphicon glyphicon-warning-sign"></span>
|
||||
<strong>This action only disables 2FA.</strong>
|
||||
</p>
|
||||
<p>
|
||||
Disabling 2FA does not change the keys used in authenticator apps. If you wish to change the key
|
||||
used in an authenticator app you should <a asp-action="ResetAuthenticatorWarning">reset your
|
||||
authenticator keys.</a>
|
||||
</p>
|
||||
<p>
|
||||
<span class="glyphicon glyphicon-warning-sign"></span>
|
||||
<strong>This action only disables 2FA.</strong>
|
||||
</p>
|
||||
<p>
|
||||
Disabling 2FA does not change the keys used in authenticator apps. If you wish to change the key
|
||||
used in an authenticator app you should <a asp-action="ResetAuthenticatorWarning">
|
||||
reset your
|
||||
authenticator keys.
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<form asp-action="Disable2fa" method="post" class="form-group">
|
||||
<button class="btn btn-danger" type="submit">Disable 2FA</button>
|
||||
</form>
|
||||
<form asp-action="Disable2fa" method="post" class="form-group">
|
||||
<button class="btn btn-danger" type="submit">Disable 2FA</button>
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
@model GenerateRecoveryCodesViewModel
|
||||
@{
|
||||
ViewData["Title"] = "Recovery codes";
|
||||
ViewData.AddActivePage(ManageNavPages.TwoFactorAuthentication);
|
||||
ViewData["Title"] = "Recovery codes";
|
||||
ViewData.AddActivePage(ManageNavPages.TwoFactorAuthentication);
|
||||
}
|
||||
|
||||
<h4>@ViewData["Title"]</h4>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
@{
|
||||
ViewData["Title"] = "Reset authenticator key";
|
||||
ViewData.AddActivePage(ManageNavPages.TwoFactorAuthentication);
|
||||
ViewData["Title"] = "Reset authenticator key";
|
||||
ViewData.AddActivePage(ManageNavPages.TwoFactorAuthentication);
|
||||
}
|
||||
|
||||
<h4>@ViewData["Title"]</h4>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
@model SetPasswordViewModel
|
||||
@{
|
||||
ViewData["Title"] = "Set password";
|
||||
ViewData.AddActivePage(ManageNavPages.ChangePassword);
|
||||
ViewData["Title"] = "Set password";
|
||||
ViewData.AddActivePage(ManageNavPages.ChangePassword);
|
||||
}
|
||||
|
||||
<h4>Set your password</h4>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
@model TwoFactorAuthenticationViewModel
|
||||
@{
|
||||
ViewData["Title"] = "Two-factor authentication";
|
||||
ViewData.AddActivePage(ManageNavPages.TwoFactorAuthentication);
|
||||
ViewData["Title"] = "Two-factor authentication";
|
||||
ViewData.AddActivePage(ManageNavPages.TwoFactorAuthentication);
|
||||
}
|
||||
|
||||
<h4>@ViewData["Title"]</h4>
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
@{
|
||||
Layout = "/Views/Shared/_Layout.cshtml";
|
||||
}
|
||||
|
||||
|
||||
<section>
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-lg-12 text-center">
|
||||
<h2 class="section-heading">Manage your account</h2>
|
||||
<hr class="primary">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div class="row">
|
||||
<div class="col-md-3">
|
||||
@await Html.PartialAsync("_ManageNav")
|
||||
</div>
|
||||
<div class="col-md-9">
|
||||
@RenderBody()
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
@section Scripts {
|
||||
@RenderSection("Scripts", required: false)
|
||||
}
|
||||
|
4
BTCPayServer/Views/Manage/_ViewStart.cshtml
Normal file
4
BTCPayServer/Views/Manage/_ViewStart.cshtml
Normal file
|
@ -0,0 +1,4 @@
|
|||
@{
|
||||
Layout = "../Shared/_NavLayout.cshtml";
|
||||
ViewBag.MainTitle = "Manage your account";
|
||||
}
|
28
BTCPayServer/Views/Server/ListUsers.cshtml
Normal file
28
BTCPayServer/Views/Server/ListUsers.cshtml
Normal file
|
@ -0,0 +1,28 @@
|
|||
@model UsersViewModel
|
||||
@{
|
||||
ViewData["Title"] = "Users";
|
||||
ViewData.AddActivePage(ServerNavPages.Users);
|
||||
}
|
||||
|
||||
|
||||
<h4>@ViewData["Title"]</h4>
|
||||
@Html.Partial("_StatusMessage", Model.StatusMessage)
|
||||
|
||||
|
||||
<table class="table">
|
||||
<thead class="thead-inverse">
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Email</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach(var user in Model.Users)
|
||||
{
|
||||
<tr>
|
||||
<td>@user.Name</td>
|
||||
<td>@user.Email</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
30
BTCPayServer/Views/Server/ServerNavPages.cs
Normal file
30
BTCPayServer/Views/Server/ServerNavPages.cs
Normal file
|
@ -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;
|
||||
}
|
||||
}
|
6
BTCPayServer/Views/Server/_Nav.cshtml
Normal file
6
BTCPayServer/Views/Server/_Nav.cshtml
Normal file
|
@ -0,0 +1,6 @@
|
|||
@using BTCPayServer.Views.Server
|
||||
|
||||
<ul class="nav nav-pills nav-stacked">
|
||||
<li class="@ServerNavPages.UsersNavClass(ViewContext)"><a asp-action="Users">Users</a></li>
|
||||
</ul>
|
||||
|
2
BTCPayServer/Views/Server/_ViewImports.cshtml
Normal file
2
BTCPayServer/Views/Server/_ViewImports.cshtml
Normal file
|
@ -0,0 +1,2 @@
|
|||
@using BTCPayServer.Views.Server
|
||||
@using BTCPayServer.Models.ServerViewModels
|
4
BTCPayServer/Views/Server/_ViewStart.cshtml
Normal file
4
BTCPayServer/Views/Server/_ViewStart.cshtml
Normal file
|
@ -0,0 +1,4 @@
|
|||
@{
|
||||
Layout = "../Shared/_NavLayout.cshtml";
|
||||
ViewBag.MainTitle = "Server settings";
|
||||
}
|
|
@ -53,7 +53,7 @@
|
|||
{
|
||||
@if(User.IsInRole(Roles.ServerAdmin))
|
||||
{
|
||||
<li class="nav-item"><a asp-area="" asp-controller="Server" asp-action="Settings" class="nav-link js-scroll-trigger">Server settings</a></li>
|
||||
<li class="nav-item"><a asp-area="" asp-controller="Server" asp-action="ListUsers" class="nav-link js-scroll-trigger">Server settings</a></li>
|
||||
}
|
||||
<li class="nav-item"><a asp-area="" asp-controller="Stores" asp-action="ListStores" class="nav-link js-scroll-trigger">Stores</a></li>
|
||||
<li class="nav-item"><a asp-area="" asp-controller="Invoice" asp-action="ListInvoices" class="nav-link js-scroll-trigger">Invoices</a></li>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-lg-12 text-center">
|
||||
<h2 class="section-heading">Manage your store</h2>
|
||||
<h2 class="section-heading">@ViewData["MainTitle"]</h2>
|
||||
<hr class="primary">
|
||||
</div>
|
||||
</div>
|
||||
|
@ -15,7 +15,7 @@
|
|||
<div>
|
||||
<div class="row">
|
||||
<div class="col-md-3">
|
||||
@await Html.PartialAsync("_StoreNav")
|
||||
@await Html.PartialAsync("_Nav")
|
||||
</div>
|
||||
<div class="col-md-9">
|
||||
@RenderBody()
|
|
@ -1,6 +1,5 @@
|
|||
@model BTCPayServer.Models.StoreViewModels.CreateStoreViewModel
|
||||
@{
|
||||
Layout = "/Views/Shared/_Layout.cshtml";
|
||||
ViewData["Title"] = "Create a new store";
|
||||
}
|
||||
<section>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
@model CreateTokenViewModel
|
||||
@{
|
||||
Layout = "../Shared/_NavLayout.cshtml";
|
||||
ViewData["Title"] = "Create a new token";
|
||||
ViewData.AddActivePage(StoreNavPages.Tokens);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
@model StoresViewModel
|
||||
@{
|
||||
Layout = "/Views/Shared/_Layout.cshtml";
|
||||
ViewData["Title"] = "Stores";
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
@model TokensViewModel
|
||||
@{
|
||||
Layout = "../Shared/_NavLayout.cshtml";
|
||||
ViewData["Title"] = "Access Tokens";
|
||||
ViewData.AddActivePage(StoreNavPages.Tokens);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
@model PairingModel
|
||||
@{
|
||||
Layout = "/Views/Shared/_Layout.cshtml";
|
||||
ViewData["Title"] = "Pairing permission";
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
@model StoreViewModel
|
||||
@{
|
||||
Layout = "../Shared/_NavLayout.cshtml";
|
||||
ViewData["Title"] = "Profile";
|
||||
ViewData.AddActivePage(BTCPayServer.Views.Stores.StoreNavPages.Index);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
@using BTCPayServer.Views.Stores
|
||||
@inject SignInManager<ApplicationUser> SignInManager
|
||||
@{
|
||||
var hasExternalLogins = (await SignInManager.GetExternalAuthenticationSchemesAsync()).Any();
|
||||
}
|
||||
|
||||
<ul class="nav nav-pills nav-stacked">
|
||||
<li class="@StoreNavPages.IndexNavClass(ViewContext)"><a asp-action="UpdateStore">Information</a></li>
|
3
BTCPayServer/Views/Stores/_ViewStart.cshtml
Normal file
3
BTCPayServer/Views/Stores/_ViewStart.cshtml
Normal file
|
@ -0,0 +1,3 @@
|
|||
@{
|
||||
ViewBag.MainTitle = "Manage store";
|
||||
}
|
Loading…
Add table
Reference in a new issue