1
0
mirror of https://github.com/bitwarden/server.git synced 2025-04-06 21:48:12 -05:00

built out the organization edit event from the admin portal (#1508)

* built out the organization edit event from the admin portal

* removed unneeded override

* added some space

* fixed the space
This commit is contained in:
Addison Beck 2021-08-11 12:44:30 -04:00 committed by GitHub
parent c22dc71c49
commit f55708d748
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 19 additions and 9 deletions

View File

@ -27,6 +27,7 @@ namespace Bit.Admin.Controllers
private readonly IApplicationCacheService _applicationCacheService; private readonly IApplicationCacheService _applicationCacheService;
private readonly GlobalSettings _globalSettings; private readonly GlobalSettings _globalSettings;
private readonly IReferenceEventService _referenceEventService; private readonly IReferenceEventService _referenceEventService;
private readonly IUserService _userService;
public OrganizationsController( public OrganizationsController(
IOrganizationRepository organizationRepository, IOrganizationRepository organizationRepository,
@ -38,7 +39,8 @@ namespace Bit.Admin.Controllers
IPaymentService paymentService, IPaymentService paymentService,
IApplicationCacheService applicationCacheService, IApplicationCacheService applicationCacheService,
GlobalSettings globalSettings, GlobalSettings globalSettings,
IReferenceEventService referenceEventService) IReferenceEventService referenceEventService,
IUserService userService)
{ {
_organizationRepository = organizationRepository; _organizationRepository = organizationRepository;
_organizationUserRepository = organizationUserRepository; _organizationUserRepository = organizationUserRepository;
@ -50,6 +52,7 @@ namespace Bit.Admin.Controllers
_applicationCacheService = applicationCacheService; _applicationCacheService = applicationCacheService;
_globalSettings = globalSettings; _globalSettings = globalSettings;
_referenceEventService = referenceEventService; _referenceEventService = referenceEventService;
_userService = userService;
} }
public async Task<IActionResult> Index(string name = null, string userEmail = null, bool? paid = null, public async Task<IActionResult> Index(string name = null, string userEmail = null, bool? paid = null,
@ -137,15 +140,13 @@ namespace Bit.Admin.Controllers
public async Task<IActionResult> Edit(Guid id, OrganizationEditModel model) public async Task<IActionResult> Edit(Guid id, OrganizationEditModel model)
{ {
var organization = await _organizationRepository.GetByIdAsync(id); var organization = await _organizationRepository.GetByIdAsync(id);
if (organization == null)
{
return RedirectToAction("Index");
}
model.ToOrganization(organization); model.ToOrganization(organization);
await _organizationRepository.ReplaceAsync(organization); await _organizationRepository.ReplaceAsync(organization);
await _applicationCacheService.UpsertOrganizationAbilityAsync(organization); await _applicationCacheService.UpsertOrganizationAbilityAsync(organization);
await _referenceEventService.RaiseEventAsync(new ReferenceEvent(ReferenceEventType.SalesAssisted, organization)); await _referenceEventService.RaiseEventAsync(new ReferenceEvent(ReferenceEventType.OrganizationEditedByAdmin, organization) {
EventRaisedByUser = _userService.GetUserName(User),
SalesAssistedTrialStarted = model.SalesAssistedTrialStarted,
});
return RedirectToAction("Edit", new { id }); return RedirectToAction("Edit", new { id });
} }

View File

@ -107,6 +107,7 @@ namespace Bit.Admin.Models
public string LicenseKey { get; set; } public string LicenseKey { get; set; }
[Display(Name = "Expiration Date")] [Display(Name = "Expiration Date")]
public DateTime? ExpirationDate { get; set; } public DateTime? ExpirationDate { get; set; }
public bool SalesAssistedTrialStarted { get; set; }
public Organization ToOrganization(Organization existingOrganization) public Organization ToOrganization(Organization existingOrganization)
{ {

View File

@ -34,6 +34,8 @@
// Licensing // Licensing
document.getElementById('@(nameof(Model.LicenseKey))').value = '@Model.RandomLicenseKey'; document.getElementById('@(nameof(Model.LicenseKey))').value = '@Model.RandomLicenseKey';
document.getElementById('@(nameof(Model.ExpirationDate))').value = '@Model.FourteenDayExpirationDate'; document.getElementById('@(nameof(Model.ExpirationDate))').value = '@Model.FourteenDayExpirationDate';
document.getElementById('@(nameof(Model.SalesAssistedTrialStarted))').value = true;
}); });
document.getElementById('@(nameof(Model.PlanType))').addEventListener('change', () => { document.getElementById('@(nameof(Model.PlanType))').addEventListener('change', () => {
@ -83,6 +85,7 @@
@await Html.PartialAsync("_BillingInformation", @await Html.PartialAsync("_BillingInformation",
new BillingInformationModel { BillingInfo = Model.BillingInfo, OrganizationId = Model.Organization.Id }) new BillingInformationModel { BillingInfo = Model.BillingInfo, OrganizationId = Model.Organization.Id })
<form method="post" id="edit-form"> <form method="post" id="edit-form">
<input asp-for="SalesAssistedTrialStarted" type="hidden">
<h2>General</h2> <h2>General</h2>
<div class="row"> <div class="row">
<div class="col-sm"> <div class="col-sm">

View File

@ -38,7 +38,7 @@ namespace Bit.Core.Enums
GroupCreated, GroupCreated,
[EnumMember(Value = "collection-created")] [EnumMember(Value = "collection-created")]
CollectionCreated, CollectionCreated,
[EnumMember(Value = "sales-assisted")] [EnumMember(Value = "organization-edited-by-admin")]
SalesAssisted OrganizationEditedByAdmin
} }
} }

View File

@ -57,5 +57,9 @@ namespace Bit.Core.Models.Business
public int? MaxAccessCount { get; set; } public int? MaxAccessCount { get; set; }
public bool? HasPassword { get; set; } public bool? HasPassword { get; set; }
public string EventRaisedByUser { get; set; }
public bool SalesAssistedTrialStarted { get; set; }
} }
} }

View File

@ -73,5 +73,6 @@ namespace Bit.Core.Services
Task<string> GenerateEnterprisePortalSignInTokenAsync(User user); Task<string> GenerateEnterprisePortalSignInTokenAsync(User user);
Task<string> GenerateSignInTokenAsync(User user, string purpose); Task<string> GenerateSignInTokenAsync(User user, string purpose);
Task RotateApiKeyAsync(User user); Task RotateApiKeyAsync(User user);
string GetUserName(ClaimsPrincipal principal);
} }
} }