mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-07 11:57:55 +02:00
29 lines
1,023 B
C#
29 lines
1,023 B
C#
using MediaBrowser.Common.Net.Handlers;
|
|
using MediaBrowser.Controller;
|
|
using MediaBrowser.Model.Authentication;
|
|
using MediaBrowser.Model.Entities;
|
|
using System.ComponentModel.Composition;
|
|
using System.Net;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace MediaBrowser.Api.HttpHandlers
|
|
{
|
|
[Export(typeof(BaseHandler))]
|
|
class UserAuthenticationHandler : BaseSerializationHandler<AuthenticationResult>
|
|
{
|
|
public override bool HandlesRequest(HttpListenerRequest request)
|
|
{
|
|
return ApiService.IsApiUrlMatch("UserAuthentication", request);
|
|
}
|
|
|
|
protected override async Task<AuthenticationResult> GetObjectToSerialize()
|
|
{
|
|
string userId = await GetFormValue("userid").ConfigureAwait(false);
|
|
User user = ApiService.GetUserById(userId, false);
|
|
|
|
string password = await GetFormValue("password").ConfigureAwait(false);
|
|
|
|
return Kernel.Instance.AuthenticateUser(user, password);
|
|
}
|
|
}
|
|
}
|