mirror of
https://github.com/bitwarden/server.git
synced 2025-04-05 13:08:17 -05:00
Allow org update api on self hosted for identifier only (#898)
This commit is contained in:
parent
526bdfdb05
commit
303b9a7875
@ -177,7 +177,6 @@ namespace Bit.Api.Controllers
|
||||
|
||||
[HttpPut("{id}")]
|
||||
[HttpPost("{id}")]
|
||||
[SelfHosted(NotSelfHostedOnly = true)]
|
||||
public async Task<OrganizationResponseModel> Put(string id, [FromBody]OrganizationUpdateRequestModel model)
|
||||
{
|
||||
var orgIdGuid = new Guid(id);
|
||||
@ -192,10 +191,10 @@ namespace Bit.Api.Controllers
|
||||
throw new NotFoundException();
|
||||
}
|
||||
|
||||
var updatebilling = model.BusinessName != organization.BusinessName ||
|
||||
model.BillingEmail != organization.BillingEmail;
|
||||
var updatebilling = !_globalSettings.SelfHosted && (model.BusinessName != organization.BusinessName ||
|
||||
model.BillingEmail != organization.BillingEmail);
|
||||
|
||||
await _organizationService.UpdateAsync(model.ToOrganization(organization), updatebilling);
|
||||
await _organizationService.UpdateAsync(model.ToOrganization(organization, _globalSettings), updatebilling);
|
||||
return new OrganizationResponseModel(organization);
|
||||
}
|
||||
|
||||
|
@ -17,11 +17,15 @@ namespace Bit.Core.Models.Api
|
||||
[StringLength(50)]
|
||||
public string BillingEmail { get; set; }
|
||||
|
||||
public virtual Organization ToOrganization(Organization existingOrganization)
|
||||
public virtual Organization ToOrganization(Organization existingOrganization, GlobalSettings globalSettings)
|
||||
{
|
||||
existingOrganization.Name = Name;
|
||||
existingOrganization.BusinessName = BusinessName;
|
||||
existingOrganization.BillingEmail = BillingEmail?.ToLowerInvariant()?.Trim();
|
||||
if (!globalSettings.SelfHosted)
|
||||
{
|
||||
// These items come from the license file
|
||||
existingOrganization.Name = Name;
|
||||
existingOrganization.BusinessName = BusinessName;
|
||||
existingOrganization.BillingEmail = BillingEmail?.ToLowerInvariant()?.Trim();
|
||||
}
|
||||
existingOrganization.Identifier = Identifier;
|
||||
return existingOrganization;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user