From fdb4b501e24b680f888faa2f0f425173c553df4b Mon Sep 17 00:00:00 2001 From: "Jamie.Rees" Date: Fri, 28 Oct 2016 08:57:21 +0100 Subject: [PATCH] Fixed #621 --- PlexRequests.UI/Modules/UserLoginModule.cs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/PlexRequests.UI/Modules/UserLoginModule.cs b/PlexRequests.UI/Modules/UserLoginModule.cs index 7ae55f511..d4e55182c 100644 --- a/PlexRequests.UI/Modules/UserLoginModule.cs +++ b/PlexRequests.UI/Modules/UserLoginModule.cs @@ -147,17 +147,17 @@ namespace PlexRequests.UI.Modules { Log.Debug("Need to auth"); authenticated = CheckIfUserIsInPlexFriends(username, plexSettings.PlexAuthToken); + if (authenticated) + { + userId = GetUserIdIsInPlexFriends(username, plexSettings.PlexAuthToken); + } if (CheckIfUserIsOwner(plexSettings.PlexAuthToken, username)) { Log.Debug("User is the account owner"); authenticated = true; + userId = GetOwnerId(plexSettings.PlexAuthToken, username); } Log.Debug("Friends list result = {0}", authenticated); - if (authenticated) - { - // Get the user that is authenticated to store in the UserLogins - userId = GetUserIdIsInPlexFriends(username, plexSettings.PlexAuthToken); - } } else if (!settings.UserAuthentication) // No auth, let them pass! { @@ -218,6 +218,16 @@ namespace PlexRequests.UI.Modules return userAccount.Username != null && userAccount.Username.Equals(userName, StringComparison.CurrentCultureIgnoreCase); } + private string GetOwnerId(string authToken, string userName) + { + var userAccount = Api.GetAccount(authToken); + if (userAccount == null) + { + return string.Empty; + } + return userAccount.Id; + } + private bool CheckIfUserIsInPlexFriends(string username, string authToken) { var users = Api.GetUsers(authToken);