From 13563b604756152fe2f6630a4cb8fd2994e5bb62 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 25 Feb 2014 23:38:21 -0500 Subject: Add upnp configuration --- MediaBrowser.Api/UserService.cs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'MediaBrowser.Api/UserService.cs') diff --git a/MediaBrowser.Api/UserService.cs b/MediaBrowser.Api/UserService.cs index 8e94d2c83..18c3bd096 100644 --- a/MediaBrowser.Api/UserService.cs +++ b/MediaBrowser.Api/UserService.cs @@ -189,7 +189,7 @@ namespace MediaBrowser.Api { throw new ArgumentNullException("xmlSerializer"); } - + _xmlSerializer = xmlSerializer; _userManager = userManager; _dtoService = dtoService; @@ -306,6 +306,26 @@ namespace MediaBrowser.Api var auth = AuthorizationRequestFilterAttribute.GetAuthorization(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)) + { + 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) + }; + } + var session = await _sessionMananger.AuthenticateNewSession(user, request.Password, auth.Client, auth.Version, auth.DeviceId, auth.Device, Request.RemoteIp).ConfigureAwait(false); -- cgit v1.2.3