aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Api/UserService.cs
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2014-07-02 14:34:08 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2014-07-02 14:34:08 -0400
commit59dc591f66c20b6417aa2baa9503a154585386f9 (patch)
tree68ee71de2e4162550bb95f5e661ef413ddf1e046 /MediaBrowser.Api/UserService.cs
parent9bab99d4d8659e69478722d72028e84b64575ab2 (diff)
update to jquery mobile 1.4.3
Diffstat (limited to 'MediaBrowser.Api/UserService.cs')
-rw-r--r--MediaBrowser.Api/UserService.cs63
1 files changed, 12 insertions, 51 deletions
diff --git a/MediaBrowser.Api/UserService.cs b/MediaBrowser.Api/UserService.cs
index 764a28102..64d1fcb34 100644
--- a/MediaBrowser.Api/UserService.cs
+++ b/MediaBrowser.Api/UserService.cs
@@ -269,28 +269,6 @@ namespace MediaBrowser.Api
/// <param name="request">The request.</param>
public object Post(AuthenticateUser request)
{
- // No response needed. Will throw an exception on failure.
- var result = AuthenticateUser(request).Result;
-
- return result;
- }
-
- public object Post(AuthenticateUserByName request)
- {
- var user = _userManager.Users.FirstOrDefault(i => string.Equals(request.Username, i.Name, StringComparison.OrdinalIgnoreCase));
-
- if (user == null)
- {
- throw new ArgumentException(string.Format("User {0} not found.", request.Username));
- }
-
- var result = AuthenticateUser(new AuthenticateUser { Id = user.Id, Password = request.Password }).Result;
-
- return ToOptimizedResult(result);
- }
-
- private async Task<AuthenticationResult> AuthenticateUser(AuthenticateUser request)
- {
var user = _userManager.GetUserById(request.Id);
if (user == null)
@@ -298,38 +276,21 @@ namespace MediaBrowser.Api
throw new ResourceNotFoundException("User not found");
}
- var auth = AuthorizationContext.GetAuthorizationInfo(Request);
-
- // Login in the old way if the header is missing
- if (string.IsNullOrEmpty(auth.Client) ||
- string.IsNullOrEmpty(auth.Device) ||
- string.IsNullOrEmpty(auth.DeviceId) ||
- string.IsNullOrEmpty(auth.Version))
+ return Post(new AuthenticateUserByName
{
- var success = await _userManager.AuthenticateUser(user, request.Password).ConfigureAwait(false);
-
- if (!success)
- {
- // Unauthorized
- throw new UnauthorizedAccessException("Invalid user or password entered.");
- }
-
- return new AuthenticationResult
- {
- User = _dtoService.GetUserDto(user)
- };
- }
+ Username = user.Name,
+ Password = request.Password
+ });
+ }
- var session = await _sessionMananger.AuthenticateNewSession(user, request.Password, auth.Client, auth.Version,
- auth.DeviceId, auth.Device, Request.RemoteIp).ConfigureAwait(false);
+ public object Post(AuthenticateUserByName request)
+ {
+ var auth = AuthorizationContext.GetAuthorizationInfo(Request);
- var result = new AuthenticationResult
- {
- User = _dtoService.GetUserDto(user),
- SessionInfo = _sessionMananger.GetSessionInfoDto(session)
- };
+ var result = _sessionMananger.AuthenticateNewSession(request.Username, request.Password, auth.Client, auth.Version,
+ auth.DeviceId, auth.Device, Request.RemoteIp).Result;
- return result;
+ return ToOptimizedResult(result);
}
/// <summary>
@@ -353,7 +314,7 @@ namespace MediaBrowser.Api
}
else
{
- var success = _userManager.AuthenticateUser(user, request.CurrentPassword).Result;
+ var success = _userManager.AuthenticateUser(user.Name, request.CurrentPassword).Result;
if (!success)
{