Fixed: Implement alternate login system with LoginCustomParameters
This commit is contained in:
parent
0f0f9ebc66
commit
fd06b974d5
3 changed files with 144 additions and 43 deletions
|
@ -189,7 +189,7 @@ const std::string& CLoginStateMachine::toString(CLoginStateMachine::TEvent event
|
|||
break; \
|
||||
} \
|
||||
|
||||
extern std::string LoginLogin, LoginPassword;
|
||||
extern std::string LoginLogin, LoginPassword, LoginCustomParameters;
|
||||
extern bool noUserChar;
|
||||
extern bool userChar;
|
||||
extern bool serverReceivedReady;
|
||||
|
@ -247,6 +247,8 @@ void CLoginStateMachine::run()
|
|||
if (!ClientCfg.TestBrowser)
|
||||
{
|
||||
if (LoginLogin.empty())
|
||||
{
|
||||
if (LoginCustomParameters.empty())
|
||||
{
|
||||
// standard procedure
|
||||
SM_BEGIN_EVENT_TABLE
|
||||
|
@ -256,6 +258,16 @@ void CLoginStateMachine::run()
|
|||
SM_END_EVENT_TABLE
|
||||
}
|
||||
else
|
||||
{
|
||||
// alternate login procedure
|
||||
SM_BEGIN_EVENT_TABLE
|
||||
SM_EVENT(ev_init_done, st_alt_login);
|
||||
SM_EVENT(ev_skip_all_login, st_ingame);
|
||||
SM_EVENT(ev_quit, st_end);
|
||||
SM_END_EVENT_TABLE
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// login 2, bypass the login screen
|
||||
SM_BEGIN_EVENT_TABLE
|
||||
|
@ -325,6 +337,27 @@ void CLoginStateMachine::run()
|
|||
// SM_EVENT(ev_login_ok, st_check_patch);
|
||||
// SM_EVENT(ev_quit, st_end);
|
||||
// SM_END_EVENT_TABLE
|
||||
// }
|
||||
break;
|
||||
case st_alt_login:
|
||||
initAltLogin();
|
||||
|
||||
// if (ClientCfg.R2Mode)
|
||||
{
|
||||
// r2 mode
|
||||
SM_BEGIN_EVENT_TABLE
|
||||
SM_EVENT(ev_login_not_alt, st_login);
|
||||
SM_EVENT(ev_login_ok, st_check_patch);
|
||||
SM_EVENT(ev_quit, st_end);
|
||||
SM_END_EVENT_TABLE
|
||||
}
|
||||
// else
|
||||
// {
|
||||
// // legacy mode
|
||||
// SM_BEGIN_EVENT_TABLE
|
||||
// SM_EVENT(ev_login_ok, st_check_patch);
|
||||
// SM_EVENT(ev_quit, st_end);
|
||||
// SM_END_EVENT_TABLE
|
||||
// }
|
||||
break;
|
||||
case st_shard_list:
|
||||
|
|
|
@ -81,6 +81,8 @@ public:
|
|||
st_rate_session,
|
||||
/// create account
|
||||
st_create_account,
|
||||
/// try to login with alternate login system
|
||||
st_alt_login,
|
||||
/// pseudo state to leave the state machine
|
||||
st_end,
|
||||
///
|
||||
|
@ -156,6 +158,8 @@ public:
|
|||
ev_create_account,
|
||||
/// the client push the 'create account' button
|
||||
ev_close_create_account,
|
||||
/// the client want to use alternate login system
|
||||
ev_login_not_alt,
|
||||
///
|
||||
ev_unknown
|
||||
};
|
||||
|
@ -203,6 +207,7 @@ void initEula();
|
|||
void initPatchCheck();
|
||||
void initCatDisplay();
|
||||
void initAutoLogin();
|
||||
void initAltLogin();
|
||||
void initPatch();
|
||||
//void initWebBrowser();
|
||||
void initReboot();
|
||||
|
|
|
@ -842,6 +842,55 @@ void initAutoLogin()
|
|||
}
|
||||
}
|
||||
|
||||
void initAltLogin()
|
||||
{
|
||||
// Check the alt param
|
||||
if (!LoginCustomParameters.empty())
|
||||
{
|
||||
// don't use login and password for alternate login
|
||||
string res = checkLogin("", "", ClientApp, LoginCustomParameters);
|
||||
if (res.empty())
|
||||
{
|
||||
if (ClientCfg.R2Mode)
|
||||
{
|
||||
LoginSM.pushEvent(CLoginStateMachine::ev_login_ok);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Select good shard
|
||||
ShardSelected = -1;
|
||||
for (uint32 i = 0; i < Shards.size(); ++i)
|
||||
{
|
||||
if (Shards[i].ShardId == LoginShardId)
|
||||
{
|
||||
ShardSelected = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ShardSelected == -1)
|
||||
{
|
||||
CInterfaceManager *pIM = CInterfaceManager::getInstance();
|
||||
pIM->messageBoxWithHelp(CI18N::get("uiErrServerLost"), "ui:login");
|
||||
LoginSM.pushEvent(CLoginStateMachine::ev_quit);
|
||||
}
|
||||
else
|
||||
{
|
||||
LoginSM.pushEvent(CLoginStateMachine::ev_login_ok);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// close the socket in case of error
|
||||
HttpClient.disconnect();
|
||||
|
||||
// ignore error
|
||||
LoginSM.pushEvent(CLoginStateMachine::ev_login_not_alt);
|
||||
}
|
||||
|
||||
|
||||
// ***************************************************************************
|
||||
// Called from client.cpp
|
||||
|
@ -2732,6 +2781,9 @@ string checkLogin(const string &login, const string &password, const string &cli
|
|||
|
||||
string res;
|
||||
|
||||
// don't use login with alt method
|
||||
if (!login.empty())
|
||||
{
|
||||
// ask server for salt
|
||||
if(!HttpClient.sendGet(ClientCfg.ConfigFile.getVar("StartupPage").asString()+"?cmd=ask&login="+login+"&lg="+ClientCfg.LanguageCode, "", pPM->isVerboseLog()))
|
||||
return "Can't send (error code 60)";
|
||||
|
@ -2768,13 +2820,24 @@ string checkLogin(const string &login, const string &password, const string &cli
|
|||
return "Can't connect (error code 63)";
|
||||
|
||||
if(pPM->isVerboseLog()) nlinfo("Connected");
|
||||
}
|
||||
|
||||
if (ClientCfg.R2Mode)
|
||||
{
|
||||
// R2 login sequence
|
||||
|
||||
if (!login.empty())
|
||||
{
|
||||
std::string cryptedPassword = CCrypt::crypt(password, Salt);
|
||||
if(!HttpClient.sendGet(ClientCfg.ConfigFile.getVar("StartupPage").asString()+"?cmd=login&login="+login+"&password="+cryptedPassword+"&clientApplication="+clientApp+"&cp=1"+"&lg="+ClientCfg.LanguageCode+customParameters))
|
||||
return "Can't send (error code 2)";
|
||||
}
|
||||
else
|
||||
{
|
||||
// don't send login and password if empty
|
||||
if(!HttpClient.sendGet(ClientCfg.ConfigFile.getVar("StartupPage").asString()+"?cmd=login&clientApplication="+clientApp+"&cp=1"+"&lg="+ClientCfg.LanguageCode+customParameters))
|
||||
return "Can't send (error code 2)";
|
||||
}
|
||||
|
||||
// the response should contains the result code and the cookie value
|
||||
if(pPM->isVerboseLog()) nlinfo("Sent request login check");
|
||||
|
|
Loading…
Reference in a new issue