jellyfin-server/MediaBrowser.Api/HttpHandlers/UserAuthenticationHandler.cs
LukePulverenti Luke Pulverenti luke pulverenti 2467ca9668 Moved some entities to the main project
2012-09-10 21:34:02 -04:00

30 lines
1.0 KiB
C#

using MediaBrowser.Common.Net.Handlers;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Model.Authentication;
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);
}
}
}