mirror of
https://github.com/bitwarden/server.git
synced 2025-05-20 11:04:31 -05:00
user/org view pages
This commit is contained in:
parent
af70fdb6c5
commit
bd3457fc06
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.5" />
|
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.5" />
|
||||||
|
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.2" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -53,6 +53,18 @@ namespace Bit.Admin.Controllers
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<IActionResult> View(Guid id)
|
||||||
|
{
|
||||||
|
var organization = await _organizationRepository.GetByIdAsync(id);
|
||||||
|
if(organization == null)
|
||||||
|
{
|
||||||
|
return RedirectToAction("Index");
|
||||||
|
}
|
||||||
|
|
||||||
|
var users = await _organizationUserRepository.GetManyDetailsByOrganizationAsync(id);
|
||||||
|
return View(new OrganizationViewModel(organization, users));
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<IActionResult> Edit(Guid id)
|
public async Task<IActionResult> Edit(Guid id)
|
||||||
{
|
{
|
||||||
var organization = await _organizationRepository.GetByIdAsync(id);
|
var organization = await _organizationRepository.GetByIdAsync(id);
|
||||||
|
@ -50,6 +50,18 @@ namespace Bit.Admin.Controllers
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<IActionResult> View(Guid id)
|
||||||
|
{
|
||||||
|
var user = await _userRepository.GetByIdAsync(id);
|
||||||
|
if(user == null)
|
||||||
|
{
|
||||||
|
return RedirectToAction("Index");
|
||||||
|
}
|
||||||
|
|
||||||
|
var ciphers = await _cipherRepository.GetManyByUserIdAsync(id);
|
||||||
|
return View(new UserViewModel(user, ciphers));
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<IActionResult> Edit(Guid id)
|
public async Task<IActionResult> Edit(Guid id)
|
||||||
{
|
{
|
||||||
var user = await _userRepository.GetByIdAsync(id);
|
var user = await _userRepository.GetByIdAsync(id);
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Linq;
|
|
||||||
using Bit.Core;
|
using Bit.Core;
|
||||||
using Bit.Core.Enums;
|
using Bit.Core.Enums;
|
||||||
using Bit.Core.Models.Data;
|
using Bit.Core.Models.Data;
|
||||||
@ -10,17 +9,14 @@ using Bit.Core.Utilities;
|
|||||||
|
|
||||||
namespace Bit.Admin.Models
|
namespace Bit.Admin.Models
|
||||||
{
|
{
|
||||||
public class OrganizationEditModel
|
public class OrganizationEditModel : OrganizationViewModel
|
||||||
{
|
{
|
||||||
public OrganizationEditModel() { }
|
public OrganizationEditModel() { }
|
||||||
|
|
||||||
public OrganizationEditModel(Organization org, IEnumerable<OrganizationUserUserDetails> orgUsers,
|
public OrganizationEditModel(Organization org, IEnumerable<OrganizationUserUserDetails> orgUsers,
|
||||||
GlobalSettings globalSettings)
|
GlobalSettings globalSettings)
|
||||||
|
: base(org, orgUsers)
|
||||||
{
|
{
|
||||||
Organization = org;
|
|
||||||
UserCount = orgUsers.Count();
|
|
||||||
Owners = string.Join(", ", orgUsers.Where(u => u.Type == OrganizationUserType.Owner).Select(u => u.Email));
|
|
||||||
Admins = string.Join(", ", orgUsers.Where(u => u.Type == OrganizationUserType.Admin).Select(u => u.Email));
|
|
||||||
BraintreeMerchantId = globalSettings.Braintree.MerchantId;
|
BraintreeMerchantId = globalSettings.Braintree.MerchantId;
|
||||||
|
|
||||||
Name = org.Name;
|
Name = org.Name;
|
||||||
@ -50,10 +46,6 @@ namespace Bit.Admin.Models
|
|||||||
ExpirationDate = org.ExpirationDate;
|
ExpirationDate = org.ExpirationDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Organization Organization { get; set; }
|
|
||||||
public string Owners { get; set; }
|
|
||||||
public string Admins { get; set; }
|
|
||||||
public int UserCount { get; set; }
|
|
||||||
public string RandomLicenseKey => CoreHelpers.SecureRandomString(20);
|
public string RandomLicenseKey => CoreHelpers.SecureRandomString(20);
|
||||||
public string FourteenDayExpirationDate => DateTime.Now.AddDays(14).ToString("yyyy-MM-ddTHH:mm");
|
public string FourteenDayExpirationDate => DateTime.Now.AddDays(14).ToString("yyyy-MM-ddTHH:mm");
|
||||||
public string BraintreeMerchantId { get; set; }
|
public string BraintreeMerchantId { get; set; }
|
||||||
|
27
src/Admin/Models/OrganizationViewModel.cs
Normal file
27
src/Admin/Models/OrganizationViewModel.cs
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using Bit.Core.Enums;
|
||||||
|
using Bit.Core.Models.Data;
|
||||||
|
using Bit.Core.Models.Table;
|
||||||
|
|
||||||
|
namespace Bit.Admin.Models
|
||||||
|
{
|
||||||
|
public class OrganizationViewModel
|
||||||
|
{
|
||||||
|
public OrganizationViewModel() { }
|
||||||
|
|
||||||
|
public OrganizationViewModel(Organization org, IEnumerable<OrganizationUserUserDetails> orgUsers)
|
||||||
|
{
|
||||||
|
Organization = org;
|
||||||
|
UserCount = orgUsers.Count();
|
||||||
|
Owners = string.Join(", ", orgUsers.Where(u => u.Type == OrganizationUserType.Owner).Select(u => u.Email));
|
||||||
|
Admins = string.Join(", ", orgUsers.Where(u => u.Type == OrganizationUserType.Admin).Select(u => u.Email));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Organization Organization { get; set; }
|
||||||
|
public string Owners { get; set; }
|
||||||
|
public string Admins { get; set; }
|
||||||
|
public int UserCount { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -8,14 +8,13 @@ using Bit.Core.Utilities;
|
|||||||
|
|
||||||
namespace Bit.Admin.Models
|
namespace Bit.Admin.Models
|
||||||
{
|
{
|
||||||
public class UserEditModel
|
public class UserEditModel : UserViewModel
|
||||||
{
|
{
|
||||||
public UserEditModel() { }
|
public UserEditModel() { }
|
||||||
|
|
||||||
public UserEditModel(User user, IEnumerable<Cipher> ciphers, GlobalSettings globalSettings)
|
public UserEditModel(User user, IEnumerable<Cipher> ciphers, GlobalSettings globalSettings)
|
||||||
|
: base(user, ciphers)
|
||||||
{
|
{
|
||||||
User = user;
|
|
||||||
CipherCount = ciphers.Count();
|
|
||||||
BraintreeMerchantId = globalSettings.Braintree.MerchantId;
|
BraintreeMerchantId = globalSettings.Braintree.MerchantId;
|
||||||
|
|
||||||
Name = user.Name;
|
Name = user.Name;
|
||||||
@ -30,8 +29,6 @@ namespace Bit.Admin.Models
|
|||||||
PremiumExpirationDate = user.PremiumExpirationDate;
|
PremiumExpirationDate = user.PremiumExpirationDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public User User { get; set; }
|
|
||||||
public int CipherCount { get; set; }
|
|
||||||
public string RandomLicenseKey => CoreHelpers.SecureRandomString(20);
|
public string RandomLicenseKey => CoreHelpers.SecureRandomString(20);
|
||||||
public string OneYearExpirationDate => DateTime.Now.AddYears(1).ToString("yyyy-MM-ddTHH:mm");
|
public string OneYearExpirationDate => DateTime.Now.AddYears(1).ToString("yyyy-MM-ddTHH:mm");
|
||||||
public string BraintreeMerchantId { get; set; }
|
public string BraintreeMerchantId { get; set; }
|
||||||
|
21
src/Admin/Models/UserViewModel.cs
Normal file
21
src/Admin/Models/UserViewModel.cs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using Bit.Core.Models.Table;
|
||||||
|
|
||||||
|
namespace Bit.Admin.Models
|
||||||
|
{
|
||||||
|
public class UserViewModel
|
||||||
|
{
|
||||||
|
public UserViewModel() { }
|
||||||
|
|
||||||
|
public UserViewModel(User user, IEnumerable<Cipher> ciphers)
|
||||||
|
{
|
||||||
|
User = user;
|
||||||
|
CipherCount = ciphers.Count();
|
||||||
|
}
|
||||||
|
|
||||||
|
public User User { get; set; }
|
||||||
|
public int CipherCount { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -74,25 +74,7 @@
|
|||||||
<h1>Organization <small>@Model.Organization.Name</small></h1>
|
<h1>Organization <small>@Model.Organization.Name</small></h1>
|
||||||
|
|
||||||
<h2>Information</h2>
|
<h2>Information</h2>
|
||||||
<dl class="row">
|
@Html.Partial("_ViewInformation", Model)
|
||||||
<dt class="col-sm-2">Id</dt>
|
|
||||||
<dd class="col-sm-10"><code>@Model.Organization.Id</code></dd>
|
|
||||||
|
|
||||||
<dt class="col-sm-2">Users</dt>
|
|
||||||
<dd class="col-sm-10">@Model.UserCount</dd>
|
|
||||||
|
|
||||||
<dt class="col-sm-2">Owners</dt>
|
|
||||||
<dd class="col-sm-10">@(string.IsNullOrWhiteSpace(Model.Owners) ? "None" : Model.Owners)</dd>
|
|
||||||
|
|
||||||
<dt class="col-sm-2">Admins</dt>
|
|
||||||
<dd class="col-sm-10">@(string.IsNullOrWhiteSpace(Model.Admins) ? "None" : Model.Admins)</dd>
|
|
||||||
|
|
||||||
<dt class="col-sm-2">Created</dt>
|
|
||||||
<dd class="col-sm-10">@Model.Organization.CreationDate.ToString()</dd>
|
|
||||||
|
|
||||||
<dt class="col-sm-2">Modified</dt>
|
|
||||||
<dd class="col-sm-10">@Model.Organization.RevisionDate.ToString()</dd>
|
|
||||||
</dl>
|
|
||||||
<form method="post" id="edit-form">
|
<form method="post" id="edit-form">
|
||||||
<h2>General</h2>
|
<h2>General</h2>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
13
src/Admin/Views/Organizations/View.cshtml
Normal file
13
src/Admin/Views/Organizations/View.cshtml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
@model OrganizationViewModel
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "Organization: " + Model.Organization.Name;
|
||||||
|
}
|
||||||
|
|
||||||
|
<h1>Organization <small>@Model.Organization.Name</small></h1>
|
||||||
|
|
||||||
|
<h2>Information</h2>
|
||||||
|
@Html.Partial("_ViewInformation", Model)
|
||||||
|
<form asp-action="Delete" asp-route-id="@Model.Organization.Id"
|
||||||
|
onsubmit="return confirm('Are you sure you want to delete this organization (@Model.Organization.Name)?')">
|
||||||
|
<button class="btn btn-danger" type="submit">Delete</button>
|
||||||
|
</form>
|
20
src/Admin/Views/Organizations/_ViewInformation.cshtml
Normal file
20
src/Admin/Views/Organizations/_ViewInformation.cshtml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
@model OrganizationViewModel
|
||||||
|
<dl class="row">
|
||||||
|
<dt class="col-sm-2">Id</dt>
|
||||||
|
<dd class="col-sm-10"><code>@Model.Organization.Id</code></dd>
|
||||||
|
|
||||||
|
<dt class="col-sm-2">Users</dt>
|
||||||
|
<dd class="col-sm-10">@Model.UserCount</dd>
|
||||||
|
|
||||||
|
<dt class="col-sm-2">Owners</dt>
|
||||||
|
<dd class="col-sm-10">@(string.IsNullOrWhiteSpace(Model.Owners) ? "None" : Model.Owners)</dd>
|
||||||
|
|
||||||
|
<dt class="col-sm-2">Admins</dt>
|
||||||
|
<dd class="col-sm-10">@(string.IsNullOrWhiteSpace(Model.Admins) ? "None" : Model.Admins)</dd>
|
||||||
|
|
||||||
|
<dt class="col-sm-2">Created</dt>
|
||||||
|
<dd class="col-sm-10">@Model.Organization.CreationDate.ToString()</dd>
|
||||||
|
|
||||||
|
<dt class="col-sm-2">Modified</dt>
|
||||||
|
<dd class="col-sm-10">@Model.Organization.RevisionDate.ToString()</dd>
|
||||||
|
</dl>
|
@ -57,22 +57,7 @@
|
|||||||
<h1>User <small>@Model.User.Email</small></h1>
|
<h1>User <small>@Model.User.Email</small></h1>
|
||||||
|
|
||||||
<h2>Information</h2>
|
<h2>Information</h2>
|
||||||
<dl class="row">
|
@Html.Partial("_ViewInformation", Model)
|
||||||
<dt class="col-sm-2">Id</dt>
|
|
||||||
<dd class="col-sm-10"><code>@Model.User.Id</code></dd>
|
|
||||||
|
|
||||||
<dt class="col-sm-2">Items</dt>
|
|
||||||
<dd class="col-sm-10">@Model.CipherCount</dd>
|
|
||||||
|
|
||||||
<dt class="col-sm-2">Created</dt>
|
|
||||||
<dd class="col-sm-10">@Model.User.CreationDate.ToString()</dd>
|
|
||||||
|
|
||||||
<dt class="col-sm-2">Modified</dt>
|
|
||||||
<dd class="col-sm-10">@Model.User.RevisionDate.ToString()</dd>
|
|
||||||
|
|
||||||
<dt class="col-sm-2">Account Modified</dt>
|
|
||||||
<dd class="col-sm-10">@Model.User.AccountRevisionDate.ToString()</dd>
|
|
||||||
</dl>
|
|
||||||
<form method="post" id="edit-form">
|
<form method="post" id="edit-form">
|
||||||
<h2>General</h2>
|
<h2>General</h2>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
13
src/Admin/Views/Users/View.cshtml
Normal file
13
src/Admin/Views/Users/View.cshtml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
@model UserViewModel
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "User: " + Model.User.Email;
|
||||||
|
}
|
||||||
|
|
||||||
|
<h1>User <small>@Model.User.Email</small></h1>
|
||||||
|
|
||||||
|
<h2>Information</h2>
|
||||||
|
@Html.Partial("_ViewInformation", Model)
|
||||||
|
<form asp-action="Delete" asp-route-id="@Model.User.Id"
|
||||||
|
onsubmit="return confirm('Are you sure you want to delete this user (@Model.User.Email)?')">
|
||||||
|
<button class="btn btn-danger" type="submit">Delete</button>
|
||||||
|
</form>
|
17
src/Admin/Views/Users/_ViewInformation.cshtml
Normal file
17
src/Admin/Views/Users/_ViewInformation.cshtml
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
@model UserViewModel
|
||||||
|
<dl class="row">
|
||||||
|
<dt class="col-sm-2">Id</dt>
|
||||||
|
<dd class="col-sm-10"><code>@Model.User.Id</code></dd>
|
||||||
|
|
||||||
|
<dt class="col-sm-2">Items</dt>
|
||||||
|
<dd class="col-sm-10">@Model.CipherCount</dd>
|
||||||
|
|
||||||
|
<dt class="col-sm-2">Created</dt>
|
||||||
|
<dd class="col-sm-10">@Model.User.CreationDate.ToString()</dd>
|
||||||
|
|
||||||
|
<dt class="col-sm-2">Modified</dt>
|
||||||
|
<dd class="col-sm-10">@Model.User.RevisionDate.ToString()</dd>
|
||||||
|
|
||||||
|
<dt class="col-sm-2">Account Modified</dt>
|
||||||
|
<dd class="col-sm-10">@Model.User.AccountRevisionDate.ToString()</dd>
|
||||||
|
</dl>
|
Loading…
x
Reference in New Issue
Block a user