fixed re-login after wrong passwd. Patch from Electron

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7669 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2014-11-08 19:31:16 +00:00
parent f7f1da01b5
commit 04b3b432e8
3 changed files with 24 additions and 53 deletions

View File

@ -97,6 +97,11 @@ bool RsAccountsDetail::lockPreferredAccount()
return false; return false;
} }
void RsAccountsDetail::unlockPreferredAccount()
{
mAccountsLocked = false;
}
bool RsAccountsDetail::selectAccountByString(const std::string &prefUserString) bool RsAccountsDetail::selectAccountByString(const std::string &prefUserString)
{ {
@ -1196,45 +1201,6 @@ bool RsInit::LoadPassword(const std::string& id, const std::string& inPwd)
} }
#endif #endif
std::string RsAccountsDetail::getHomePath()
{
std::string home;
/******************************** WINDOWS/UNIX SPECIFIC PART ******************/
#ifndef WINDOWS_SYS /* UNIX */
home = getenv("HOME");
#else /* Windows */
char *h2 = getenv("HOMEDRIVE");
char *h3 = getenv("HOMEPATH");
if(!h2)
{
// Might be Win95/98
// generate default.
home = "C:\\Retro";
}
else
{
home = h2;
home += h3;
home += "\\Desktop";
}
std::cerr << "fltkserver::getHomePath() -> " << home << std::endl;
// convert to desired format.
home = RsDirUtil::convertPathToUnix(home);
#endif
/******************************** WINDOWS/UNIX SPECIFIC PART ******************/
return home;
}
/********************************************************************************* /*********************************************************************************
* PUBLIC INTERFACE FUNCTIONS * PUBLIC INTERFACE FUNCTIONS
********************************************************************************/ ********************************************************************************/

View File

@ -70,6 +70,7 @@ class RsAccountsDetail
bool setupBaseDirectory(std::string alt_basedir); bool setupBaseDirectory(std::string alt_basedir);
bool loadAccounts(); bool loadAccounts();
bool lockPreferredAccount(); bool lockPreferredAccount();
void unlockPreferredAccount();
// Paths. // Paths.
std::string PathDataDirectory(); std::string PathDataDirectory();
@ -127,8 +128,6 @@ class RsAccountsDetail
bool defaultBaseDirectory(); bool defaultBaseDirectory();
std::string getHomePath() ;
bool getAvailableAccounts(std::map<RsPeerId, AccountDetails> &accounts, bool getAvailableAccounts(std::map<RsPeerId, AccountDetails> &accounts,
int& failing_accounts, int& failing_accounts,
std::map<std::string,std::vector<std::string> >& unsupported_keys); std::map<std::string,std::vector<std::string> >& unsupported_keys);

View File

@ -625,33 +625,39 @@ int RsInit::LockAndLoadCertificates(bool autoLoginNT, std::string& lockFilePath
return 3; // invalid PreferredAccount. return 3; // invalid PreferredAccount.
} }
int retVal = 0;
// Logic that used to be external to RsInit... // Logic that used to be external to RsInit...
RsPeerId accountId; RsPeerId accountId;
if (!rsAccounts->getPreferredAccountId(accountId)) if (!rsAccounts->getPreferredAccountId(accountId))
{ {
return 3; // invalid PreferredAccount; retVal = 3; // invalid PreferredAccount;
} }
RsPgpId pgpId; RsPgpId pgpId;
std::string pgpName, pgpEmail, location; std::string pgpName, pgpEmail, location;
if (!rsAccounts->getAccountDetails(accountId, pgpId, pgpName, pgpEmail, location)) if (retVal == 0 && !rsAccounts->getAccountDetails(accountId, pgpId, pgpName, pgpEmail, location))
return 3; // invalid PreferredAccount; retVal = 3; // invalid PreferredAccount;
if (!rsAccounts->SelectPGPAccount(pgpId)) if (retVal == 0 && !rsAccounts->SelectPGPAccount(pgpId))
return 3; // PGP Error. retVal = 3; // PGP Error.
int retVal = LockConfigDirectory(rsAccounts->PathAccountDirectory(), lockFilePath); if(retVal == 0)
if(retVal != 0) retVal = LockConfigDirectory(rsAccounts->PathAccountDirectory(), lockFilePath);
return retVal;
retVal = LoadCertificates(autoLoginNT); if(retVal == 0 && LoadCertificates(autoLoginNT) != 1)
if(retVal != 1) { {
UnlockConfigDirectory(); UnlockConfigDirectory();
return 3; retVal = 3;
} }
return 0; if(retVal != 0)
{
rsAccounts->unlockPreferredAccount();
}
return retVal;
} }