jellyfin-server/MediaBrowser.Api/HttpHandlers/UserAuthenticationHandler.cs

29 lines
981 B
C#
Raw Normal View History

2012-09-07 16:17:39 +00:00
using MediaBrowser.Common.Net.Handlers;
2012-09-06 18:38:29 +00:00
using MediaBrowser.Controller;
using MediaBrowser.Model.Entities;
using System.ComponentModel.Composition;
using System.Net;
2012-09-07 16:17:39 +00:00
using System.Threading.Tasks;
2012-09-06 18:38:29 +00:00
namespace MediaBrowser.Api.HttpHandlers
{
[Export(typeof(BaseHandler))]
2012-09-06 18:38:29 +00:00
class UserAuthenticationHandler : BaseSerializationHandler<AuthenticationResult>
{
public override bool HandlesRequest(HttpListenerRequest request)
{
return ApiService.IsApiUrlMatch("UserAuthentication", request);
}
2012-09-06 18:38:29 +00:00
protected override async Task<AuthenticationResult> GetObjectToSerialize()
{
2012-09-07 16:17:39 +00:00
string userId = await GetFormValue("userid").ConfigureAwait(false);
User user = ApiService.GetUserById(userId, false);
2012-09-06 18:38:29 +00:00
string password = await GetFormValue("password").ConfigureAwait(false);
2012-09-07 16:17:39 +00:00
return Kernel.Instance.AuthenticateUser(user, password);
2012-09-06 18:38:29 +00:00
}
}
}