1
0
mirror of https://github.com/bitwarden/server.git synced 2025-04-10 23:58:13 -05:00

api cleanup

This commit is contained in:
Kyle Spearrin 2018-07-16 17:20:57 -04:00
parent 49947e382d
commit c6c03697b1
2 changed files with 13 additions and 24 deletions

View File

@ -5,8 +5,6 @@ using Microsoft.AspNetCore.Mvc;
using Bit.Core.Models.Api; using Bit.Core.Models.Api;
using Bit.Core.Exceptions; using Bit.Core.Exceptions;
using Bit.Core.Services; using Bit.Core.Services;
using Microsoft.AspNetCore.Identity;
using Bit.Core.Models.Table;
using Bit.Core.Enums; using Bit.Core.Enums;
using System.Linq; using System.Linq;
using Bit.Core.Repositories; using Bit.Core.Repositories;

View File

@ -8,8 +8,6 @@ using Bit.Core.Models.Api;
using Bit.Core.Exceptions; using Bit.Core.Exceptions;
using Bit.Core.Services; using Bit.Core.Services;
using Bit.Core; using Bit.Core;
using Microsoft.AspNetCore.Identity;
using Bit.Core.Models.Table;
using Bit.Api.Utilities; using Bit.Api.Utilities;
using Bit.Core.Models.Business; using Bit.Core.Models.Business;
using jsreport.AspNetCore; using jsreport.AspNetCore;
@ -224,10 +222,9 @@ namespace Bit.Api.Controllers
return new OrganizationResponseModel(organization); return new OrganizationResponseModel(organization);
} }
[HttpPut("{id}/payment")]
[HttpPost("{id}/payment")] [HttpPost("{id}/payment")]
[SelfHosted(NotSelfHostedOnly = true)] [SelfHosted(NotSelfHostedOnly = true)]
public async Task PutPayment(string id, [FromBody]PaymentRequestModel model) public async Task PostPayment(string id, [FromBody]PaymentRequestModel model)
{ {
var orgIdGuid = new Guid(id); var orgIdGuid = new Guid(id);
if(!_currentContext.OrganizationOwner(orgIdGuid)) if(!_currentContext.OrganizationOwner(orgIdGuid))
@ -238,10 +235,9 @@ namespace Bit.Api.Controllers
await _organizationService.ReplacePaymentMethodAsync(orgIdGuid, model.PaymentToken); await _organizationService.ReplacePaymentMethodAsync(orgIdGuid, model.PaymentToken);
} }
[HttpPut("{id}/upgrade")]
[HttpPost("{id}/upgrade")] [HttpPost("{id}/upgrade")]
[SelfHosted(NotSelfHostedOnly = true)] [SelfHosted(NotSelfHostedOnly = true)]
public async Task PutUpgrade(string id, [FromBody]OrganizationUpgradeRequestModel model) public async Task PostUpgrade(string id, [FromBody]OrganizationUpgradeRequestModel model)
{ {
var orgIdGuid = new Guid(id); var orgIdGuid = new Guid(id);
if(!_currentContext.OrganizationOwner(orgIdGuid)) if(!_currentContext.OrganizationOwner(orgIdGuid))
@ -252,10 +248,9 @@ namespace Bit.Api.Controllers
await _organizationService.UpgradePlanAsync(orgIdGuid, model.PlanType, model.AdditionalSeats); await _organizationService.UpgradePlanAsync(orgIdGuid, model.PlanType, model.AdditionalSeats);
} }
[HttpPut("{id}/seat")]
[HttpPost("{id}/seat")] [HttpPost("{id}/seat")]
[SelfHosted(NotSelfHostedOnly = true)] [SelfHosted(NotSelfHostedOnly = true)]
public async Task PutSeat(string id, [FromBody]OrganizationSeatRequestModel model) public async Task PostSeat(string id, [FromBody]OrganizationSeatRequestModel model)
{ {
var orgIdGuid = new Guid(id); var orgIdGuid = new Guid(id);
if(!_currentContext.OrganizationOwner(orgIdGuid)) if(!_currentContext.OrganizationOwner(orgIdGuid))
@ -266,10 +261,9 @@ namespace Bit.Api.Controllers
await _organizationService.AdjustSeatsAsync(orgIdGuid, model.SeatAdjustment.Value); await _organizationService.AdjustSeatsAsync(orgIdGuid, model.SeatAdjustment.Value);
} }
[HttpPut("{id}/storage")]
[HttpPost("{id}/storage")] [HttpPost("{id}/storage")]
[SelfHosted(NotSelfHostedOnly = true)] [SelfHosted(NotSelfHostedOnly = true)]
public async Task PutStorage(string id, [FromBody]StorageRequestModel model) public async Task PostStorage(string id, [FromBody]StorageRequestModel model)
{ {
var orgIdGuid = new Guid(id); var orgIdGuid = new Guid(id);
if(!_currentContext.OrganizationOwner(orgIdGuid)) if(!_currentContext.OrganizationOwner(orgIdGuid))
@ -293,10 +287,9 @@ namespace Bit.Api.Controllers
await _organizationService.VerifyBankAsync(orgIdGuid, model.Amount1.Value, model.Amount2.Value); await _organizationService.VerifyBankAsync(orgIdGuid, model.Amount1.Value, model.Amount2.Value);
} }
[HttpPut("{id}/cancel")]
[HttpPost("{id}/cancel")] [HttpPost("{id}/cancel")]
[SelfHosted(NotSelfHostedOnly = true)] [SelfHosted(NotSelfHostedOnly = true)]
public async Task PutCancel(string id) public async Task PostCancel(string id)
{ {
var orgIdGuid = new Guid(id); var orgIdGuid = new Guid(id);
if(!_currentContext.OrganizationOwner(orgIdGuid)) if(!_currentContext.OrganizationOwner(orgIdGuid))
@ -307,10 +300,9 @@ namespace Bit.Api.Controllers
await _organizationService.CancelSubscriptionAsync(orgIdGuid, true); await _organizationService.CancelSubscriptionAsync(orgIdGuid, true);
} }
[HttpPut("{id}/reinstate")]
[HttpPost("{id}/reinstate")] [HttpPost("{id}/reinstate")]
[SelfHosted(NotSelfHostedOnly = true)] [SelfHosted(NotSelfHostedOnly = true)]
public async Task PutReinstate(string id) public async Task PostReinstate(string id)
{ {
var orgIdGuid = new Guid(id); var orgIdGuid = new Guid(id);
if(!_currentContext.OrganizationOwner(orgIdGuid)) if(!_currentContext.OrganizationOwner(orgIdGuid))
@ -367,10 +359,9 @@ namespace Bit.Api.Controllers
} }
} }
[HttpPut("{id}/license")]
[HttpPost("{id}/license")] [HttpPost("{id}/license")]
[SelfHosted(SelfHostedOnly = true)] [SelfHosted(SelfHostedOnly = true)]
public async Task PutLicense(string id, LicenseRequestModel model) public async Task PostLicense(string id, LicenseRequestModel model)
{ {
var orgIdGuid = new Guid(id); var orgIdGuid = new Guid(id);
if(!_currentContext.OrganizationOwner(orgIdGuid)) if(!_currentContext.OrganizationOwner(orgIdGuid))