diff options
Diffstat (limited to 'MediaBrowser.Api/HttpHandlers/UserAuthenticationHandler.cs')
| -rw-r--r-- | MediaBrowser.Api/HttpHandlers/UserAuthenticationHandler.cs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/MediaBrowser.Api/HttpHandlers/UserAuthenticationHandler.cs b/MediaBrowser.Api/HttpHandlers/UserAuthenticationHandler.cs new file mode 100644 index 000000000..fa9d97598 --- /dev/null +++ b/MediaBrowser.Api/HttpHandlers/UserAuthenticationHandler.cs @@ -0,0 +1,29 @@ +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);
+ }
+ }
+}
|
