mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-02 22:08:27 +01:00
Add api key functions
This commit is contained in:
@@ -1210,15 +1210,15 @@ namespace MediaBrowser.Server.Implementations.Session
|
||||
/// <returns>Task{SessionInfo}.</returns>
|
||||
/// <exception cref="System.UnauthorizedAccessException">Invalid user or password entered.</exception>
|
||||
/// <exception cref="UnauthorizedAccessException"></exception>
|
||||
public async Task<AuthenticationResult> AuthenticateNewSession(string username,
|
||||
string password,
|
||||
string clientType,
|
||||
string appVersion,
|
||||
string deviceId,
|
||||
string deviceName,
|
||||
public async Task<AuthenticationResult> AuthenticateNewSession(string username,
|
||||
string password,
|
||||
string clientType,
|
||||
string appVersion,
|
||||
string deviceId,
|
||||
string deviceName,
|
||||
string remoteEndPoint)
|
||||
{
|
||||
var result = (IsLocalhost(remoteEndPoint) && string.Equals(clientType, "Dashboard", StringComparison.OrdinalIgnoreCase)) ||
|
||||
var result = (IsLocalhost(remoteEndPoint) && string.Equals(clientType, "Dashboard", StringComparison.OrdinalIgnoreCase)) ||
|
||||
await _userManager.AuthenticateUser(username, password).ConfigureAwait(false);
|
||||
|
||||
if (!result)
|
||||
@@ -1332,6 +1332,11 @@ namespace MediaBrowser.Server.Implementations.Session
|
||||
}
|
||||
}
|
||||
|
||||
public Task RevokeToken(string token)
|
||||
{
|
||||
return Logout(token);
|
||||
}
|
||||
|
||||
private bool IsLocalhost(string remoteEndpoint)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(remoteEndpoint))
|
||||
|
||||
@@ -62,14 +62,28 @@ namespace MediaBrowser.Server.Implementations.Session
|
||||
|
||||
void connection_Closed(object sender, EventArgs e)
|
||||
{
|
||||
var capabilities = new SessionCapabilities
|
||||
if (!GetActiveSockets().Any())
|
||||
{
|
||||
PlayableMediaTypes = Session.PlayableMediaTypes,
|
||||
SupportedCommands = Session.SupportedCommands,
|
||||
SupportsMediaControl = SupportsMediaControl
|
||||
};
|
||||
try
|
||||
{
|
||||
_sessionManager.ReportSessionEnded(Session.Id);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.ErrorException("Error reporting session ended.", ex);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var capabilities = new SessionCapabilities
|
||||
{
|
||||
PlayableMediaTypes = Session.PlayableMediaTypes,
|
||||
SupportedCommands = Session.SupportedCommands,
|
||||
SupportsMediaControl = SupportsMediaControl
|
||||
};
|
||||
|
||||
_sessionManager.ReportCapabilities(Session.Id, capabilities);
|
||||
_sessionManager.ReportCapabilities(Session.Id, capabilities);
|
||||
}
|
||||
}
|
||||
|
||||
private IWebSocketConnection GetActiveSocket()
|
||||
|
||||
Reference in New Issue
Block a user