Browse Source

handle unauthorized jellyfin server (#186)

pull/187/head v0.0.36-prealpha
Jason Dove 4 years ago committed by GitHub
parent
commit
3ec838da68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      ErsatzTV.Application/Jellyfin/Commands/SynchronizeJellyfinAdminUserIdHandler.cs
  2. 2
      ErsatzTV/Pages/JellyfinMediaSources.razor

16
ErsatzTV.Application/Jellyfin/Commands/SynchronizeJellyfinAdminUserIdHandler.cs

@ -54,14 +54,24 @@ namespace ErsatzTV.Application.Jellyfin.Commands @@ -54,14 +54,24 @@ namespace ErsatzTV.Application.Jellyfin.Commands
parameters.ActiveConnection.Address,
parameters.ApiKey);
return maybeUserId.Match<Either<BaseError, Unit>>(
return await maybeUserId.Match(
userId =>
{
_logger.LogDebug("Jellyfin admin user id is {UserId}", userId);
_memoryCache.Set($"jellyfin_admin_user_id.{parameters.JellyfinMediaSource.Id}", userId);
return Unit.Default;
return Task.FromResult<Either<BaseError, Unit>>(Unit.Default);
},
error => error);
async error =>
{
// clear api key if unable to sync with jellyfin
if (error.Value.Contains("Unauthorized"))
{
await _jellyfinSecretStore.SaveSecrets(
new JellyfinSecrets { Address = parameters.ActiveConnection.Address, ApiKey = null });
}
return Left<BaseError, Unit>(error);
});
}
private Task<Validation<BaseError, ConnectionParameters>> Validate(SynchronizeJellyfinAdminUserId request) =>

2
ErsatzTV/Pages/JellyfinMediaSources.razor

@ -67,7 +67,7 @@ @@ -67,7 +67,7 @@
Color="Color.Secondary"
Link="/media/jellyfin/edit"
Class="ml-4 mt-4">
Fix Jellyfin Credentials
Fix Jellyfin Connection
</MudButton>
}

Loading…
Cancel
Save