mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-12-24 01:34:45 +03:00
Add quick connect
This commit is contained in:
@@ -117,6 +117,17 @@ namespace MediaBrowser.Api
|
||||
public string Pw { get; set; }
|
||||
}
|
||||
|
||||
[Route("/Users/AuthenticateWithQuickConnect", "POST", Summary = "Authenticates a user")]
|
||||
public class AuthenticateUserQuickConnect : IReturn<AuthenticationResult>
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the token.
|
||||
/// </summary>
|
||||
/// <value>The token</value>
|
||||
[ApiMember(Name = "Token", IsRequired = true, DataType = "string", ParameterType = "body", Verb = "POST")]
|
||||
public string Token { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Class UpdateUserPassword
|
||||
/// </summary>
|
||||
@@ -430,6 +441,29 @@ namespace MediaBrowser.Api
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<object> Post(AuthenticateUserQuickConnect request)
|
||||
{
|
||||
var auth = _authContext.GetAuthorizationInfo(Request);
|
||||
|
||||
try
|
||||
{
|
||||
var result = await _sessionMananger.AuthenticateQuickConnect(new AuthenticationRequest
|
||||
{
|
||||
App = auth.Client,
|
||||
AppVersion = auth.Version,
|
||||
DeviceId = auth.DeviceId,
|
||||
DeviceName = auth.Device
|
||||
}, request.Token).ConfigureAwait(false);
|
||||
|
||||
return ToOptimizedResult(result);
|
||||
}
|
||||
catch (SecurityException e)
|
||||
{
|
||||
// rethrow adding IP address to message
|
||||
throw new SecurityException($"[{Request.RemoteIp}] {e.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Posts the specified request.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user