From 8501c2ca7e106173108a265d6aa09e7bf0dff661 Mon Sep 17 00:00:00 2001 From: Andy Pack Date: Wed, 25 Jan 2023 22:11:57 +0000 Subject: [PATCH] saving token --- Selector.MAUI/Pages/Launch.razor | 2 +- Selector.MAUI/Services/SessionManager.cs | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Selector.MAUI/Pages/Launch.razor b/Selector.MAUI/Pages/Launch.razor index 25dcc1d..36c4eb0 100644 --- a/Selector.MAUI/Pages/Launch.razor +++ b/Selector.MAUI/Pages/Launch.razor @@ -11,7 +11,7 @@ { logger.LogInformation("Starting up"); - //await sessionManager.LoadUserFromDisk(); + await sessionManager.LoadUserFromDisk(); if (sessionManager.IsLoggedIn) { diff --git a/Selector.MAUI/Services/SessionManager.cs b/Selector.MAUI/Services/SessionManager.cs index 516bda8..c1ba20f 100644 --- a/Selector.MAUI/Services/SessionManager.cs +++ b/Selector.MAUI/Services/SessionManager.cs @@ -22,7 +22,8 @@ public class SessionManager public async Task LoadUserFromDisk() { - var lastToken = await SecureStorage.Default.GetAsync(jwt_keychain_key); + //var lastToken = await SecureStorage.Default.GetAsync(jwt_keychain_key); + var lastToken = Preferences.Default.Get(jwt_keychain_key, string.Empty); lastStoredKey = lastToken; @@ -60,6 +61,8 @@ public class SessionManager lastRefresh = DateTime.Now; //await SecureStorage.Default.SetAsync(jwt_keychain_key, lastStoredKey); + // I know, but I can't get secure storage to work + Preferences.Default.Set(jwt_keychain_key, lastStoredKey); break; case SelectorNetClient.TokenResponseStatus.Malformed: @@ -80,5 +83,11 @@ public class SessionManager return tokenResponse.Status; } + + public void SignOut() + { + lastStoredKey = null; + Preferences.Default.Clear(); + } }