Files
server/src/Api/Controllers/UsersController.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

35 lines
904 B
C#
Raw Normal View History

using Bit.Api.Models.Response;
2017-03-04 21:28:41 -05:00
using Bit.Core.Exceptions;
using Bit.Core.Repositories;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace Bit.Api.Controllers
2017-03-04 21:28:41 -05:00
{
[Route("users")]
[Authorize("Application")]
public class UsersController : Controller
2017-03-04 21:28:41 -05:00
{
private readonly IUserRepository _userRepository;
2017-03-04 21:28:41 -05:00
public UsersController(
IUserRepository userRepository)
2017-03-04 21:28:41 -05:00
{
_userRepository = userRepository;
2017-03-04 21:28:41 -05:00
}
[HttpGet("{id}/public-key")]
public async Task<UserKeyResponseModel> Get(string id)
{
var guidId = new Guid(id);
var key = await _userRepository.GetPublicKeyAsync(guidId);
if (key == null)
{
throw new NotFoundException();
}
return new UserKeyResponseModel(guidId, key);
}
2017-03-04 21:28:41 -05:00
}
}