Don't clear password if downloading error, fix #4549

This commit is contained in:
Benau 2021-07-14 10:47:14 +08:00
parent f22f4a52ef
commit 5ec426b275
3 changed files with 8 additions and 5 deletions

View File

@ -184,7 +184,7 @@ namespace Online
if(isSuccess()) if(isSuccess())
login->loginSuccessful(); login->loginSuccessful();
else else
login->loginError(getInfo()); login->loginError(getInfo(), !hadDownloadError());
} // if dialog } // if dialog
// Check if failure happened during automatic (saved) signin. // Check if failure happened during automatic (saved) signin.
@ -205,7 +205,8 @@ namespace Online
// this function is called from the main thread, so we can // this function is called from the main thread, so we can
// push screens without synchronisations. // push screens without synchronisations.
UserScreen::getInstance()->push(); UserScreen::getInstance()->push();
UserScreen::getInstance()->loginError(getInfo()); UserScreen::getInstance()->loginError(getInfo(),
!hadDownloadError());
} }

View File

@ -604,13 +604,15 @@ void BaseUserScreen::loginSuccessful()
/** Callback from player profile if login was unsuccessful. /** Callback from player profile if login was unsuccessful.
* \param error_message Contains the error message. * \param error_message Contains the error message.
*/ */
void BaseUserScreen::loginError(const irr::core::stringw & error_message) void BaseUserScreen::loginError(const irr::core::stringw & error_message,
bool clear_password)
{ {
m_state = (UserScreenState) (m_state & ~STATE_LOGIN); m_state = (UserScreenState) (m_state & ~STATE_LOGIN);
PlayerProfile *player = getSelectedPlayer(); PlayerProfile *player = getSelectedPlayer();
// Clear information about saved session in case of a problem, // Clear information about saved session in case of a problem,
// which allows the player to enter a new password. // which allows the player to enter a new password.
if(player && player->hasSavedSession()) // Only if not a download error
if(clear_password && player && player->hasSavedSession())
player->clearSession(); player->clearSession();
player->setLastOnlineName(""); player->setLastOnlineName("");
makeEntryFieldsVisible(); makeEntryFieldsVisible();

View File

@ -125,7 +125,7 @@ public:
const core::stringw &online_name="", const core::stringw &online_name="",
const core::stringw &password=""); const core::stringw &password="");
void loginSuccessful(); void loginSuccessful();
void loginError(const irr::core::stringw &error_message); void loginError(const irr::core::stringw &error_message, bool clear_password);
void logoutSuccessful(); void logoutSuccessful();
void logoutError(const irr::core::stringw &error_message); void logoutError(const irr::core::stringw &error_message);