Remember password better

This commit is contained in:
Flakebi 2014-06-06 11:31:52 +02:00
parent 03255a4156
commit de4e45280b
4 changed files with 25 additions and 48 deletions

View File

@ -170,7 +170,7 @@ PlayerManager::~PlayerManager()
PlayerProfile *player;
for_in(player, m_all_players)
{
if(player->rememberPassword())
if(!player->rememberPassword())
player->clearSession();
}
save();

View File

@ -207,7 +207,7 @@ void PlayerProfile::save(UTFWriter &out)
<< L"\" saved-token=\"" << m_saved_token << L"\"\n";
out << L" last-online-name=\"" << m_last_online_name
<< L"\" last-was-online=\"" << m_last_was_online << L"\"\n";
out << L" remember-password=\"" << m_remember_password << L"\">\n";
out << L" remember-password=\"" << m_remember_password << L"\">\n";
{
if(m_story_mode_status)
m_story_mode_status->save(out);

View File

@ -189,7 +189,7 @@ namespace Online
m_online_state = OS_SIGNED_IN;
if(rememberPassword())
{
saveSession(getOnlineId(), getToken() );
saveSession(getOnlineId(), getToken());
}
ProfileManager::get()->addPersistent(m_profile);
std::string achieved_string("");

View File

@ -73,8 +73,6 @@ void BaseUserScreen::init()
m_info_widget = getWidget<LabelWidget>("message");
assert(m_info_widget);
getWidget<CheckBoxWidget>("remember-user")
->setState(false);
m_sign_out_name = "";
m_sign_in_name = "";
@ -87,7 +85,7 @@ void BaseUserScreen::init()
Screen::init();
m_players->clearItems();
std::string current_player_index="";
int current_player_index = -1;
for (unsigned int n=0; n<PlayerManager::get()->getNumPlayers(); n++)
{
@ -96,40 +94,20 @@ void BaseUserScreen::init()
std::string s = StringUtils::toString(n);
m_players->addItem(player->getName(), s, player->getIconFilename(), 0,
IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE);
if(player==PlayerManager::getCurrentPlayer())
current_player_index = s;
if(player == PlayerManager::getCurrentPlayer())
current_player_index = n;
}
m_players->updateItemDisplay();
// Select the current player. That can only be done after
// updateItemDisplay is called.
if(current_player_index.size()>0)
{
m_players->setSelection(current_player_index, PLAYER_ID_GAME_MASTER,
/*focus*/ true);
PlayerProfile *player = PlayerManager::getCurrentPlayer();
const stringw &online_name = player->getLastOnlineName();
m_username_tb->setText(online_name);
// Select 'online
m_online_cb->setState(player->wasOnlineLastTime() ||
player->isLoggedIn() );
getWidget<CheckBoxWidget>("remember-user")->setState(
player->rememberPassword());
makeEntryFieldsVisible();
// We have to deactivate after make visible (since make visible
// automatically activates widgets).
if(online_name.size()>0)
m_username_tb->setDeactivated();
else
m_username_tb->setActivated();
}
else // no current player found
{
// The first player is the most frequently used, so select it
if (PlayerManager::get()->getNumPlayers() > 0)
selectUser(0);
}
if(current_player_index != -1)
selectUser(current_player_index);
// no current player found
// The first player is the most frequently used, so select it
else if (PlayerManager::get()->getNumPlayers() > 0)
selectUser(0);
} // init
@ -159,7 +137,8 @@ void BaseUserScreen::selectUser(int index)
PlayerProfile *profile = PlayerManager::get()->getPlayer(index);
assert(profile);
m_players->setSelection(StringUtils::toString(index), 0, /*focusIt*/true);
m_players->setSelection(StringUtils::toString(index), PLAYER_ID_GAME_MASTER,
/*focusIt*/ true);
// Last game was not online, so make the offline settings the default
// (i.e. unckeck online checkbox, and make entry fields invisible).
@ -255,21 +234,19 @@ void BaseUserScreen::eventCallback(Widget* widget,
{
// If online access is not allowed, do not accept an online account
// but advice the user where to enable this option.
if (m_online_cb->getState() && UserConfigParams::m_internet_status ==
if (m_online_cb->getState())
{
if (UserConfigParams::m_internet_status ==
Online::RequestManager::IPERM_NOT_ALLOWED)
{
m_info_widget->setText(
_("Internet access is disabled, please enable it in the options"),
true);
sfx_manager->quickSound( "anvil" );
m_online_cb->setState(false);
} else
{
m_username_tb->setText("");
m_password_tb->setText("");
getWidget<CheckBoxWidget>("remember-user")->setState(false);
makeEntryFieldsVisible();
{
m_info_widget->setText(
_("Internet access is disabled, please enable it in the options"),
true);
sfx_manager->quickSound( "anvil" );
m_online_cb->setState(false);
}
}
makeEntryFieldsVisible();
}
else if (name == "options")
{