diff options
| author | Bond-009 <bond.009@outlook.com> | 2020-08-31 23:01:27 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-08-31 23:01:27 +0200 |
| commit | 8ee042483a2b6cc5f25f1eef05650a8ff4296923 (patch) | |
| tree | e1588518cf37d1720724c47a55fd1bb84de3c8d3 /Jellyfin.Api/Controllers/UserController.cs | |
| parent | 43a81366a623b54668ceda13d5d47740e39c9855 (diff) | |
| parent | df0d197dc8509b38c6b4e5bd9ec442810bc0c647 (diff) | |
Merge pull request #2888 from ConfusedPolarBear/quickconnect
Add quick connect (login without typing password)
Diffstat (limited to 'Jellyfin.Api/Controllers/UserController.cs')
| -rw-r--r-- | Jellyfin.Api/Controllers/UserController.cs | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/Jellyfin.Api/Controllers/UserController.cs b/Jellyfin.Api/Controllers/UserController.cs index 272312522..d67f82219 100644 --- a/Jellyfin.Api/Controllers/UserController.cs +++ b/Jellyfin.Api/Controllers/UserController.cs @@ -217,6 +217,40 @@ namespace Jellyfin.Api.Controllers } /// <summary> + /// Authenticates a user with quick connect. + /// </summary> + /// <param name="request">The <see cref="QuickConnectDto"/> request.</param> + /// <response code="200">User authenticated.</response> + /// <response code="400">Missing token.</response> + /// <returns>A <see cref="Task"/> containing an <see cref="AuthenticationRequest"/> with information about the new session.</returns> + [HttpPost("AuthenticateWithQuickConnect")] + [ProducesResponseType(StatusCodes.Status200OK)] + public async Task<ActionResult<AuthenticationResult>> AuthenticateWithQuickConnect([FromBody, Required] QuickConnectDto request) + { + var auth = _authContext.GetAuthorizationInfo(Request); + + try + { + var authRequest = new AuthenticationRequest + { + App = auth.Client, + AppVersion = auth.Version, + DeviceId = auth.DeviceId, + DeviceName = auth.Device, + }; + + return await _sessionManager.AuthenticateQuickConnect( + authRequest, + request.Token).ConfigureAwait(false); + } + catch (SecurityException e) + { + // rethrow adding IP address to message + throw new SecurityException($"[{HttpContext.Connection.RemoteIpAddress}] {e.Message}", e); + } + } + + /// <summary> /// Updates a user's password. /// </summary> /// <param name="userId">The user id.</param> |
