Merge pull request #4422 from crobibero/users-me
Add /Users/Me endpoint
This commit is contained in:
commit
40453da089
|
@ -530,6 +530,33 @@ namespace Jellyfin.Api.Controllers
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the user based on auth token.
|
||||||
|
/// </summary>
|
||||||
|
/// <response code="200">User returned.</response>
|
||||||
|
/// <response code="400">Token is not owned by a user.</response>
|
||||||
|
/// <returns>A <see cref="UserDto"/> for the authenticated user.</returns>
|
||||||
|
[HttpGet("Me")]
|
||||||
|
[Authorize(Policy = Policies.DefaultAuthorization)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
|
public ActionResult<UserDto> GetCurrentUser()
|
||||||
|
{
|
||||||
|
var userId = ClaimHelpers.GetUserId(Request.HttpContext.User);
|
||||||
|
if (userId == null)
|
||||||
|
{
|
||||||
|
return BadRequest();
|
||||||
|
}
|
||||||
|
|
||||||
|
var user = _userManager.GetUserById(userId.Value);
|
||||||
|
if (user == null)
|
||||||
|
{
|
||||||
|
return BadRequest();
|
||||||
|
}
|
||||||
|
|
||||||
|
return _userManager.GetUserDto(user);
|
||||||
|
}
|
||||||
|
|
||||||
private IEnumerable<UserDto> Get(bool? isHidden, bool? isDisabled, bool filterByDevice, bool filterByNetwork)
|
private IEnumerable<UserDto> Get(bool? isHidden, bool? isDisabled, bool filterByDevice, bool filterByNetwork)
|
||||||
{
|
{
|
||||||
var users = _userManager.Users;
|
var users = _userManager.Users;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user