diff options
| author | Luke <luke.pulverenti@gmail.com> | 2013-02-20 17:10:49 -0800 |
|---|---|---|
| committer | Luke <luke.pulverenti@gmail.com> | 2013-02-20 17:10:49 -0800 |
| commit | 845554722efaed872948a9e0f7202e3ef52f1b6e (patch) | |
| tree | 534ab2d11fe4824ed303bb01e885b330631b657e /MediaBrowser.Api/HttpHandlers/UserAuthenticationHandler.cs | |
| parent | 2f142263f080f7b012a0ec2095d350ccf75b49b7 (diff) | |
| parent | 14bbb6804718ef78a8118fe750896ba679e3b6cb (diff) | |
Merge pull request #1 from MediaBrowser/Repo
Repo
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);
+ }
+ }
+}
|
