Skip to content

Commit

Permalink
refactor: relogin
Browse files Browse the repository at this point in the history
  • Loading branch information
nattb8 committed May 29, 2024
1 parent a69cab4 commit dc99377
Showing 1 changed file with 9 additions and 16 deletions.
25 changes: 9 additions & 16 deletions Assets/Shared/Scripts/UI/MainMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,16 @@ async void OnEnable()
#endif
passport = await Passport.Init(clientId, environment, redirectUri, logoutUri);

// Check if the player is supposed to be logged in
if (SaveManager.Instance.IsLoggedIn)
// Check if the player is supposed to be logged in and if there are credentials saved
if (SaveManager.Instance.IsLoggedIn && await Passport.Instance.HasCredentialsSaved())
{
// Check if there are credentials saved
bool hasCredentialsSaved = await Passport.Instance.HasCredentialsSaved();
if (hasCredentialsSaved)
{
// Try to log in using saved credentials
bool success = await Passport.Instance.Login(useCachedSession: true);
// Update the login flag
SaveManager.Instance.IsLoggedIn = success;
}
else
{
// No saved credentials to re-login the player, reset the login flag
SaveManager.Instance.IsLoggedIn = false;
}
// Try to log in using saved credentials
bool success = await Passport.Instance.Login(useCachedSession: true);
// Update the login flag
SaveManager.Instance.IsLoggedIn = success;
} else {
// No saved credentials to re-login the player, reset the login flag
SaveManager.Instance.IsLoggedIn = false;
}

ShowLoading(false);
Expand Down

0 comments on commit dc99377

Please sign in to comment.