mirror of
https://github.com/rmcrackan/Libation.git
synced 2026-09-12 21:57:19 -04:00
Ported from #1949. The reporter's log paused auto-scan on a second account that had never been logged in, while the dialog blamed an expired session and named no account, so there was nothing to act on. AccountCredentialStatus tells a never-registered account apart from one holding an expired access token, by looking for a refresh token to renew from. AutoScanRunner now hands the AuthenticationRequiredException to the notification so the prompt can name the account, which means digging that exception back out of the wrappers the scan adds on the way up. Same distinction in the log line and in the exception message ApiExtended throws when interactive login is unavailable, which is what the CLI and Docker users see. Co-authored-by: rmcrackan <rmcrackan@gmail.com>
24 lines
906 B
C#
24 lines
906 B
C#
using AudibleUtilities;
|
|
using System;
|
|
|
|
namespace LibationUiBase;
|
|
|
|
/// <summary>Shared copy for the dialog shown when auto-scan pauses itself waiting for a login.</summary>
|
|
public static class AutoScanAuthPrompt
|
|
{
|
|
public const string Caption = "Auto-scan paused - login required";
|
|
|
|
public static string FormatBody(AuthenticationRequiredException ex)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(ex);
|
|
|
|
var account = AccountCredentialStatus.FormatAccountLabel(ex.Account);
|
|
var cause = AccountCredentialStatus.LooksLikeMissingCredentials(ex.Account)
|
|
? "that account has never been logged in, or its stored credentials are missing"
|
|
: "the stored login for that account expired";
|
|
|
|
return $"Libation could not refresh the Audible library for {account} because {cause}.\n\n"
|
|
+ "Background auto-scan has been paused. Use Import > Scan Library to log in for that account and resume periodic scans.";
|
|
}
|
|
}
|