aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--MediaBrowser.Api/ConnectService.cs2
-rw-r--r--MediaBrowser.Server.Implementations/Connect/ConnectManager.cs66
-rw-r--r--MediaBrowser.Server.Implementations/Connect/Responses.cs5
-rw-r--r--MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json4
-rw-r--r--MediaBrowser.Server.Implementations/Localization/Server/server.json3
5 files changed, 50 insertions, 30 deletions
diff --git a/MediaBrowser.Api/ConnectService.cs b/MediaBrowser.Api/ConnectService.cs
index 80f6d4810..4d3cad49d 100644
--- a/MediaBrowser.Api/ConnectService.cs
+++ b/MediaBrowser.Api/ConnectService.cs
@@ -23,7 +23,7 @@ namespace MediaBrowser.Api
}
[Route("/Users/{Id}/Connect/Link", "DELETE", Summary = "Removes a Connect link for a user")]
- public class DeleteConnectLink : IReturn<ConnectUserLink>
+ public class DeleteConnectLink : IReturnVoid
{
[ApiMember(Name = "Id", Description = "User Id", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "DELETE")]
public string Id { get; set; }
diff --git a/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs b/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs
index 972f3adb6..d0de64a6f 100644
--- a/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs
+++ b/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs
@@ -295,7 +295,7 @@ namespace MediaBrowser.Server.Implementations.Connect
if (!string.IsNullOrWhiteSpace(user.ConnectUserId))
{
- await RemoveLink(user, connectUser).ConfigureAwait(false);
+ await RemoveLink(user, connectUser.Id).ConfigureAwait(false);
}
var url = GetConnectUrl("ServerAuthorizations");
@@ -323,6 +323,7 @@ namespace MediaBrowser.Server.Implementations.Connect
// No need to examine the response
using (var stream = (await _httpClient.Post(options).ConfigureAwait(false)).Content)
{
+ var response = _json.DeserializeFromStream<ServerUserAuthorizationResponse>(stream);
}
user.ConnectAccessKey = accessToken;
@@ -332,44 +333,55 @@ namespace MediaBrowser.Server.Implementations.Connect
await user.UpdateToRepository(ItemUpdateType.MetadataEdit, CancellationToken.None).ConfigureAwait(false);
}
- public async Task RemoveLink(string userId)
+ public Task RemoveLink(string userId)
{
var user = GetUser(userId);
- var connectUser = await GetConnectUser(new ConnectUserQuery
- {
- Name = user.ConnectUserId
-
- }, CancellationToken.None).ConfigureAwait(false);
-
- await RemoveLink(user, connectUser).ConfigureAwait(false);
+ return RemoveLink(user, user.ConnectUserId);
}
- public async Task RemoveLink(User user, ConnectUser connectUser)
+ private async Task RemoveLink(User user, string connectUserId)
{
- var url = GetConnectUrl("ServerAuthorizations");
-
- var options = new HttpRequestOptions
+ if (!string.IsNullOrWhiteSpace(connectUserId))
{
- Url = url,
- CancellationToken = CancellationToken.None
- };
+ var url = GetConnectUrl("ServerAuthorizations");
- var postData = new Dictionary<string, string>
- {
- {"serverId", ConnectServerId},
- {"userId", connectUser.Id}
- };
+ var options = new HttpRequestOptions
+ {
+ Url = url,
+ CancellationToken = CancellationToken.None
+ };
- options.SetPostData(postData);
+ var postData = new Dictionary<string, string>
+ {
+ {"serverId", ConnectServerId},
+ {"userId", connectUserId}
+ };
- SetServerAccessToken(options);
+ options.SetPostData(postData);
- // No need to examine the response
- using (var stream = (await _httpClient.SendAsync(options, "DELETE").ConfigureAwait(false)).Content)
- {
+ SetServerAccessToken(options);
+
+ try
+ {
+ // No need to examine the response
+ using (var stream = (await _httpClient.SendAsync(options, "DELETE").ConfigureAwait(false)).Content)
+ {
+ }
+ }
+ catch (HttpException ex)
+ {
+ // If connect says the auth doesn't exist, we can handle that gracefully since this is a remove operation
+
+ if (!ex.StatusCode.HasValue || ex.StatusCode.Value != HttpStatusCode.NotFound)
+ {
+ throw;
+ }
+
+ _logger.Debug("Connect returned a 404 when removing a user auth link. Handling it.");
+ }
}
-
+
user.ConnectAccessKey = null;
user.ConnectUserName = null;
user.ConnectUserId = null;
diff --git a/MediaBrowser.Server.Implementations/Connect/Responses.cs b/MediaBrowser.Server.Implementations/Connect/Responses.cs
index 5d71c0f9b..7a80015d5 100644
--- a/MediaBrowser.Server.Implementations/Connect/Responses.cs
+++ b/MediaBrowser.Server.Implementations/Connect/Responses.cs
@@ -25,4 +25,9 @@ namespace MediaBrowser.Server.Implementations.Connect
public string IsActive { get; set; }
public string ImageUrl { get; set; }
}
+
+ public class ServerUserAuthorizationResponse
+ {
+
+ }
}
diff --git a/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json b/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json
index 07ce3e4f0..6442c3178 100644
--- a/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json
+++ b/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json
@@ -453,5 +453,7 @@
"MessageYouHaveAnActiveRecurringMembership": "You have an active {0} membership. You can upgrade your plan using the options below.",
"ButtonDelete": "Delete",
"HeaderMediaBrowserAccountAdded": "Media Browser Account Added",
- "MessageMediaBrowserAccontAdded": "A Media Browser account has been added to this user. An email will be sent to the owner of the account. The invitation will need to be confirmed by clicking a link within the email."
+ "MessageMediaBrowserAccontAdded": "A Media Browser account has been added to this user. An email will be sent to the owner of the account. The invitation will need to be confirmed by clicking a link within the email.",
+ "HeaderMediaBrowserAccountRemoved": "Media Browser Account Removed",
+ "MessageMediaBrowserAccontRemoved": "The Media Browser account has been removed from this user."
}
diff --git a/MediaBrowser.Server.Implementations/Localization/Server/server.json b/MediaBrowser.Server.Implementations/Localization/Server/server.json
index 7a3b08def..86dc60c2e 100644
--- a/MediaBrowser.Server.Implementations/Localization/Server/server.json
+++ b/MediaBrowser.Server.Implementations/Localization/Server/server.json
@@ -1160,5 +1160,6 @@
"LabelExtractChaptersDuringLibraryScan": "Extract chapter images during the library scan",
"LabelExtractChaptersDuringLibraryScanHelp": "If enabled, chapter images will be extracted when videos are imported during the library scan. If disabled they will be extracted during the chapter images scheduled task, allowing the regular library scan to complete faster.",
"LabelConnectUserName": "Media Browser username/email:",
- "LabelConnectUserNameHelp": "Connect this user to a Media Browser account to enable easy sign-in access from any app without having to know the server ip address."
+ "LabelConnectUserNameHelp": "Connect this user to a Media Browser account to enable easy sign-in access from any app without having to know the server ip address.",
+ "ButtonLearnMoreAboutMediaBrowserConnect": "Learn more about Media Browser Connect"
}