Browse Source

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
pull/1513/head
Addison Beck 4 years ago committed by GitHub
parent
commit
f55708d748
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 15
      src/Admin/Controllers/OrganizationsController.cs
  2. 1
      src/Admin/Models/OrganizationEditModel.cs
  3. 3
      src/Admin/Views/Organizations/Edit.cshtml
  4. 4
      src/Core/Enums/ReferenceEventType.cs
  5. 4
      src/Core/Models/Business/ReferenceEvent.cs
  6. 1
      src/Core/Services/IUserService.cs

15
src/Admin/Controllers/OrganizationsController.cs

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

1
src/Admin/Models/OrganizationEditModel.cs

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

3
src/Admin/Views/Organizations/Edit.cshtml

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

4
src/Core/Enums/ReferenceEventType.cs

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

4
src/Core/Models/Business/ReferenceEvent.cs

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

1
src/Core/Services/IUserService.cs

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

Loading…
Cancel
Save