Files
Libation/Source/AudibleUtilities/AccountCredentialStatus.cs
T
Cursor Agentandrmcrackan 9afcb09885 Keep account addresses out of the auto-scan pause log line
The dialog names the account in full because it is shown to whoever owns it, but
log files get attached to public issue reports, which is why the codebase has
MaskedLogEntry. Naming the account in the log the same way the dialog does would
have put real email addresses into every shared log.

Co-authored-by: rmcrackan <rmcrackan@gmail.com>
2026-08-16 18:32:37 +00:00

38 lines
1.3 KiB
C#

using Dinah.Core;
namespace AudibleUtilities;
/// <summary>Describes whether an account has usable stored Audible tokens.</summary>
public static class AccountCredentialStatus
{
/// <summary>
/// True when identity tokens are absent or carry no refresh token, meaning the account was never fully logged
/// in or its credentials were cleared, rather than merely holding an expired access token.
/// </summary>
public static bool LooksLikeMissingCredentials(Account? account)
{
if (account?.IdentityTokens is not { } tokens)
return true;
if (tokens.IsValid)
return false;
// without a refresh token there is nothing to renew from, so this needs a fresh login rather than a retry
return string.IsNullOrWhiteSpace(tokens.RefreshToken?.Value);
}
/// <summary>
/// Account label for dialogs shown to the person who owns the account. Not for logs: those get attached to
/// public issue reports, which is what <see cref="Account.MaskedLogEntry"/> is for.
/// </summary>
public static string FormatAccountLabel(Account? account)
{
if (account is null)
return "an Audible account";
return string.IsNullOrWhiteSpace(account.AccountName) || account.AccountName.EqualsInsensitive(account.AccountId)
? $"'{account.AccountId}'"
: $"'{account.AccountName}' ({account.AccountId})";
}
}