mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-07-09 23:30:50 +02:00
Apply suggestions from code review
Co-authored-by: Cody Robibero <cody@robibe.ro>
This commit is contained in:
parent
035d29fb35
commit
eaa5711534
|
@ -46,7 +46,7 @@ namespace Jellyfin.Api.Controllers
|
||||||
public ActionResult<QuickConnectState> GetStatus()
|
public ActionResult<QuickConnectState> GetStatus()
|
||||||
{
|
{
|
||||||
_quickConnect.ExpireRequests();
|
_quickConnect.ExpireRequests();
|
||||||
return Ok(_quickConnect.State);
|
return _quickConnect.State;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -60,7 +60,7 @@ namespace Jellyfin.Api.Controllers
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
public ActionResult<QuickConnectResult> Initiate([FromQuery] string? friendlyName)
|
public ActionResult<QuickConnectResult> Initiate([FromQuery] string? friendlyName)
|
||||||
{
|
{
|
||||||
return Ok(_quickConnect.TryConnect(friendlyName));
|
return _quickConnect.TryConnect(friendlyName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -78,7 +78,7 @@ namespace Jellyfin.Api.Controllers
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var result = _quickConnect.CheckRequestStatus(secret);
|
var result = _quickConnect.CheckRequestStatus(secret);
|
||||||
return Ok(result);
|
return result;
|
||||||
}
|
}
|
||||||
catch (ResourceNotFoundException)
|
catch (ResourceNotFoundException)
|
||||||
{
|
{
|
||||||
|
@ -135,12 +135,7 @@ namespace Jellyfin.Api.Controllers
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
public ActionResult<bool> Authorize([FromQuery, Required] string? code)
|
public ActionResult<bool> Authorize([FromQuery, Required] string? code)
|
||||||
{
|
{
|
||||||
if (code == null)
|
return _quickConnect.AuthorizeRequest(Request, code);
|
||||||
{
|
|
||||||
return BadRequest("Missing code");
|
|
||||||
}
|
|
||||||
|
|
||||||
return Ok(_quickConnect.AuthorizeRequest(Request, code));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -153,7 +148,7 @@ namespace Jellyfin.Api.Controllers
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
public ActionResult<int> Deauthorize()
|
public ActionResult<int> Deauthorize()
|
||||||
{
|
{
|
||||||
var userId = _authContext.GetAuthorizationInfo(Request).UserId;
|
var userId = ClaimHelpers.GetUserId(request.HttpContext.User);
|
||||||
return _quickConnect.DeleteAllDevices(userId);
|
return _quickConnect.DeleteAllDevices(userId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -227,11 +227,6 @@ namespace Jellyfin.Api.Controllers
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
public async Task<ActionResult<AuthenticationResult>> AuthenticateWithQuickConnect([FromBody, Required] QuickConnectDto request)
|
public async Task<ActionResult<AuthenticationResult>> AuthenticateWithQuickConnect([FromBody, Required] QuickConnectDto request)
|
||||||
{
|
{
|
||||||
if (request.Token == null)
|
|
||||||
{
|
|
||||||
return BadRequest("Access token is required.");
|
|
||||||
}
|
|
||||||
|
|
||||||
var auth = _authContext.GetAuthorizationInfo(Request);
|
var auth = _authContext.GetAuthorizationInfo(Request);
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the quick connect token.
|
/// Gets or sets the quick connect token.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[Required]
|
||||||
public string? Token { get; set; }
|
public string? Token { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue