From 1a764a72e534fdd6052fd90b4acde56113a0cdca Mon Sep 17 00:00:00 2001 From: Natalie Bunduwongse Date: Fri, 1 Mar 2024 14:33:53 +1300 Subject: [PATCH] feat: logout --- Assets/Shared/Prefabs/UI/MainMenu.prefab | 2 +- Assets/Shared/Scripts/UI/MainMenu.cs | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Assets/Shared/Prefabs/UI/MainMenu.prefab b/Assets/Shared/Prefabs/UI/MainMenu.prefab index 96774c24f..43002177a 100644 --- a/Assets/Shared/Prefabs/UI/MainMenu.prefab +++ b/Assets/Shared/Prefabs/UI/MainMenu.prefab @@ -1020,7 +1020,7 @@ MonoBehaviour: m_EditorClassIdentifier: m_StartButton: {fileID: 2691304556920018293} m_StartButtonEvent: {fileID: 11400000, guid: b892538bd49f3487bbedf5106c094739, type: 2} - m_ConnectedAs: {fileID: 4794305795399722571} + m_Email: {fileID: 0} m_LogoutButton: {fileID: 1880825616676340313} m_Loading: {fileID: 7960696323686974425} --- !u!1 &8405303144642299478 diff --git a/Assets/Shared/Scripts/UI/MainMenu.cs b/Assets/Shared/Scripts/UI/MainMenu.cs index 6641213b5..9d2a43844 100644 --- a/Assets/Shared/Scripts/UI/MainMenu.cs +++ b/Assets/Shared/Scripts/UI/MainMenu.cs @@ -62,7 +62,8 @@ async void OnEnable() } ShowLoading(false); - ShowStartButton(true); + // Show the logout button if the user is logged in + ShowLogoutButton(SaveManager.Instance.IsLoggedIn); } void OnDisable() @@ -76,7 +77,7 @@ void OnStartButtonClick() AudioManager.Instance.PlayEffect(SoundID.ButtonSound); } - void OnLogoutButtonClick() + async void OnLogoutButtonClick() { try { @@ -86,6 +87,11 @@ void OnLogoutButtonClick() ShowLoading(true); // Logout +#if (UNITY_ANDROID && !UNITY_EDITOR_WIN) || (UNITY_IPHONE && !UNITY_EDITOR_WIN) || UNITY_STANDALONE_OSX + await passport.LogoutPKCE(); +#else + await passport.Logout(); +#endif // Reset the login flag SaveManager.Instance.IsLoggedIn = false;