aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Api/HttpHandlers/UserAuthenticationHandler.cs
blob: 9f72aa4175b8722f7fad07c7e827ae5aaa0f280c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
using MediaBrowser.Common.Net.Handlers;
using MediaBrowser.Controller;
using MediaBrowser.Model.Entities;
using System.Threading.Tasks;

namespace MediaBrowser.Api.HttpHandlers
{
    class UserAuthenticationHandler : BaseSerializationHandler<AuthenticationResult>
    {
        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);
        }
    }
}