Add migration to re-register device fore new Identity properties.
This commit is contained in:
parent
344e675634
commit
0034d51921
@ -3,6 +3,7 @@ using System.IO;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using AudibleApi;
|
using AudibleApi;
|
||||||
|
using AudibleApi.Authorization;
|
||||||
using FileManager;
|
using FileManager;
|
||||||
using InternalUtilities;
|
using InternalUtilities;
|
||||||
using LibationWinForms;
|
using LibationWinForms;
|
||||||
@ -29,6 +30,7 @@ namespace LibationLauncher
|
|||||||
|
|
||||||
migrate_to_v4_0_0();
|
migrate_to_v4_0_0();
|
||||||
migrate_to_v4_0_3(); // add setting for whether to delete/retain aax
|
migrate_to_v4_0_3(); // add setting for whether to delete/retain aax
|
||||||
|
migrate_to_v5_x_x();
|
||||||
|
|
||||||
ensureLoggingConfig();
|
ensureLoggingConfig();
|
||||||
ensureSerilogConfig();
|
ensureSerilogConfig();
|
||||||
@ -227,6 +229,40 @@ namespace LibationLauncher
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region migrate_to_v5_x_x re-gegister device if device info not in settings
|
||||||
|
private static void migrate_to_v5_x_x()
|
||||||
|
{
|
||||||
|
if (!File.Exists(AudibleApiStorage.AccountsSettingsFile))
|
||||||
|
return;
|
||||||
|
|
||||||
|
var accountsPersister = AudibleApiStorage.GetAccountsSettingsPersister();
|
||||||
|
|
||||||
|
foreach (var account in accountsPersister.AccountsSettings.Accounts)
|
||||||
|
{
|
||||||
|
var identity = account.IdentityTokens;
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(identity.DeviceType) &&
|
||||||
|
!string.IsNullOrWhiteSpace(identity.DeviceType) &&
|
||||||
|
!string.IsNullOrWhiteSpace(identity.DeviceType))
|
||||||
|
break;
|
||||||
|
|
||||||
|
var authorize = new AudibleApi.Authorization.Authorize(identity?.Locale);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
authorize.DeregisterAsync(identity.ExistingAccessToken, identity.Cookies.ToKeyValuePair()).GetAwaiter().GetResult();
|
||||||
|
identity.Invalidate();
|
||||||
|
|
||||||
|
var api = AudibleApiActions.GetApiAsync(new LibationWinForms.Login.WinformResponder(account), account).GetAwaiter().GetResult();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// Don't care if it fails
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
private static string defaultLoggingLevel { get; } = "Information";
|
private static string defaultLoggingLevel { get; } = "Information";
|
||||||
private static void ensureLoggingConfig()
|
private static void ensureLoggingConfig()
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user