mirror of
https://github.com/bitwarden/server.git
synced 2025-07-02 16:42:50 -05:00
get installation by id
This commit is contained in:
@ -5,6 +5,7 @@ using Bit.Core.Repositories;
|
||||
using Bit.Core.Models.Api;
|
||||
using Bit.Api.Utilities;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Bit.Core.Exceptions;
|
||||
|
||||
namespace Bit.Api.Controllers
|
||||
{
|
||||
@ -20,13 +21,26 @@ namespace Bit.Api.Controllers
|
||||
_installationRepository = installationRepository;
|
||||
}
|
||||
|
||||
[HttpPost("{id}")]
|
||||
[AllowAnonymous]
|
||||
public async Task<InstallationResponseModel> Get(Guid id)
|
||||
{
|
||||
var installation = await _installationRepository.GetByIdAsync(id);
|
||||
if(installation == null)
|
||||
{
|
||||
throw new NotFoundException();
|
||||
}
|
||||
|
||||
return new InstallationResponseModel(installation, false);
|
||||
}
|
||||
|
||||
[HttpPost("")]
|
||||
[AllowAnonymous]
|
||||
public async Task<InstallationResponseModel> Post([FromBody] InstallationRequestModel model)
|
||||
{
|
||||
var installation = model.ToInstallation();
|
||||
await _installationRepository.CreateAsync(installation);
|
||||
return new InstallationResponseModel(installation);
|
||||
return new InstallationResponseModel(installation, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user