1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-02 16:42:50 -05:00

Added device identifier, APIs for updating token by identifier, Device creation/update upon signin.

This commit is contained in:
Kyle Spearrin
2016-06-21 00:08:22 -04:00
parent 8a34692e7c
commit 37ec1de7a3
12 changed files with 109 additions and 6 deletions

View File

@ -40,6 +40,19 @@ namespace Bit.Api.Controllers
return response;
}
[HttpGet("identifier/{identifier}")]
public async Task<DeviceResponseModel> GetByIdentifier(string identifier)
{
var device = await _deviceRepository.GetByIdentifierAsync(identifier, new Guid(_userManager.GetUserId(User)));
if(device == null)
{
throw new NotFoundException();
}
var response = new DeviceResponseModel(device);
return response;
}
[HttpGet("")]
public async Task<ListResponseModel<DeviceResponseModel>> Get()
{
@ -73,6 +86,21 @@ namespace Bit.Api.Controllers
return response;
}
[HttpPut("identifier/{identifier}/token")]
public async Task<DeviceResponseModel> PutToken(string identifier, [FromBody]DeviceTokenRequestModel model)
{
var device = await _deviceRepository.GetByIdentifierAsync(identifier, new Guid(_userManager.GetUserId(User)));
if(device == null)
{
throw new NotFoundException();
}
await _deviceRepository.ReplaceAsync(model.ToDevice(device));
var response = new DeviceResponseModel(device);
return response;
}
[HttpDelete("{id}")]
public async Task Delete(string id)
{