From bfb2f64ea480a35c973362f014e1caee7918b713 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 23 Sep 2016 02:20:56 -0400 Subject: check against repeat programs --- .../Connect/ConnectManager.cs | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'MediaBrowser.Server.Implementations/Connect') diff --git a/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs b/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs index e7e52a887..b2dd8ec86 100644 --- a/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs +++ b/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs @@ -403,6 +403,14 @@ namespace MediaBrowser.Server.Implementations.Connect public async Task LinkUser(string userId, string connectUsername) { + if (string.IsNullOrWhiteSpace(userId)) + { + throw new ArgumentNullException("userId"); + } + if (string.IsNullOrWhiteSpace(connectUsername)) + { + throw new ArgumentNullException("connectUsername"); + } if (string.IsNullOrWhiteSpace(ConnectServerId)) { await UpdateConnectInfo().ConfigureAwait(false); @@ -422,14 +430,6 @@ namespace MediaBrowser.Server.Implementations.Connect private async Task LinkUserInternal(string userId, string connectUsername) { - if (string.IsNullOrWhiteSpace(userId)) - { - throw new ArgumentNullException("userId"); - } - if (string.IsNullOrWhiteSpace(connectUsername)) - { - throw new ArgumentNullException("connectUsername"); - } if (string.IsNullOrWhiteSpace(ConnectServerId)) { throw new ArgumentNullException("ConnectServerId"); @@ -446,6 +446,12 @@ namespace MediaBrowser.Server.Implementations.Connect throw new ArgumentException("The Emby account has been disabled."); } + var existingUser = _userManager.Users.FirstOrDefault(i => string.Equals(i.ConnectUserId, connectUser.Id) && !string.IsNullOrWhiteSpace(i.ConnectAccessKey)); + if (existingUser != null) + { + throw new InvalidOperationException("This connect user is already linked to local user " + existingUser.Name); + } + var user = GetUser(userId); if (!string.IsNullOrWhiteSpace(user.ConnectUserId)) -- cgit v1.2.3