2012-09-06 18:38:29 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using MediaBrowser.Common.Net.Handlers;
|
|
|
|
|
using MediaBrowser.Controller;
|
|
|
|
|
using MediaBrowser.Model.DTO;
|
|
|
|
|
using MediaBrowser.Model.Entities;
|
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Api.HttpHandlers
|
|
|
|
|
{
|
|
|
|
|
class UserAuthenticationHandler : BaseSerializationHandler<AuthenticationResult>
|
|
|
|
|
{
|
|
|
|
|
protected override async Task<AuthenticationResult> GetObjectToSerialize()
|
|
|
|
|
{
|
2012-09-06 18:50:16 +00:00
|
|
|
|
Guid userId = Guid.Parse(await GetFormValue("userid").ConfigureAwait(false));
|
2012-09-06 18:38:29 +00:00
|
|
|
|
User user = Kernel.Instance.Users.First(u => u.Id == userId);
|
|
|
|
|
|
|
|
|
|
string password = await GetFormValue("password").ConfigureAwait(false);
|
|
|
|
|
|
2012-09-06 19:20:35 +00:00
|
|
|
|
return new AuthenticationResult()
|
2012-09-06 18:38:29 +00:00
|
|
|
|
{
|
2012-09-06 20:29:33 +00:00
|
|
|
|
Success = Kernel.GetMD5(password).Equals(user.Password)
|
2012-09-06 19:20:35 +00:00
|
|
|
|
};
|
2012-09-06 18:38:29 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|