mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-10 09:19:01 +00:00
Fixed: Implement alternate login system with LoginCustomParameters
--HG-- branch : compatibility-develop
This commit is contained in:
parent
d01204e972
commit
dc042a3739
3 changed files with 144 additions and 43 deletions
|
@ -189,7 +189,7 @@ const std::string& CLoginStateMachine::toString(CLoginStateMachine::TEvent event
|
||||||
break; \
|
break; \
|
||||||
} \
|
} \
|
||||||
|
|
||||||
extern std::string LoginLogin, LoginPassword;
|
extern std::string LoginLogin, LoginPassword, LoginCustomParameters;
|
||||||
extern bool noUserChar;
|
extern bool noUserChar;
|
||||||
extern bool userChar;
|
extern bool userChar;
|
||||||
extern bool serverReceivedReady;
|
extern bool serverReceivedReady;
|
||||||
|
@ -248,12 +248,24 @@ void CLoginStateMachine::run()
|
||||||
{
|
{
|
||||||
if (LoginLogin.empty())
|
if (LoginLogin.empty())
|
||||||
{
|
{
|
||||||
// standard procedure
|
if (LoginCustomParameters.empty())
|
||||||
SM_BEGIN_EVENT_TABLE
|
{
|
||||||
SM_EVENT(ev_init_done, st_login);
|
// standard procedure
|
||||||
SM_EVENT(ev_skip_all_login, st_ingame);
|
SM_BEGIN_EVENT_TABLE
|
||||||
SM_EVENT(ev_quit, st_end);
|
SM_EVENT(ev_init_done, st_login);
|
||||||
SM_END_EVENT_TABLE
|
SM_EVENT(ev_skip_all_login, st_ingame);
|
||||||
|
SM_EVENT(ev_quit, st_end);
|
||||||
|
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
|
else
|
||||||
{
|
{
|
||||||
|
@ -325,6 +337,27 @@ void CLoginStateMachine::run()
|
||||||
// SM_EVENT(ev_login_ok, st_check_patch);
|
// SM_EVENT(ev_login_ok, st_check_patch);
|
||||||
// SM_EVENT(ev_quit, st_end);
|
// SM_EVENT(ev_quit, st_end);
|
||||||
// SM_END_EVENT_TABLE
|
// 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;
|
break;
|
||||||
case st_shard_list:
|
case st_shard_list:
|
||||||
|
|
|
@ -81,6 +81,8 @@ public:
|
||||||
st_rate_session,
|
st_rate_session,
|
||||||
/// create account
|
/// create account
|
||||||
st_create_account,
|
st_create_account,
|
||||||
|
/// try to login with alternate login system
|
||||||
|
st_alt_login,
|
||||||
/// pseudo state to leave the state machine
|
/// pseudo state to leave the state machine
|
||||||
st_end,
|
st_end,
|
||||||
///
|
///
|
||||||
|
@ -156,6 +158,8 @@ public:
|
||||||
ev_create_account,
|
ev_create_account,
|
||||||
/// the client push the 'create account' button
|
/// the client push the 'create account' button
|
||||||
ev_close_create_account,
|
ev_close_create_account,
|
||||||
|
/// the client want to use alternate login system
|
||||||
|
ev_login_not_alt,
|
||||||
///
|
///
|
||||||
ev_unknown
|
ev_unknown
|
||||||
};
|
};
|
||||||
|
@ -203,6 +207,7 @@ void initEula();
|
||||||
void initPatchCheck();
|
void initPatchCheck();
|
||||||
void initCatDisplay();
|
void initCatDisplay();
|
||||||
void initAutoLogin();
|
void initAutoLogin();
|
||||||
|
void initAltLogin();
|
||||||
void initPatch();
|
void initPatch();
|
||||||
//void initWebBrowser();
|
//void initWebBrowser();
|
||||||
void initReboot();
|
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
|
// Called from client.cpp
|
||||||
|
@ -2732,49 +2781,63 @@ string checkLogin(const string &login, const string &password, const string &cli
|
||||||
|
|
||||||
string res;
|
string res;
|
||||||
|
|
||||||
// ask server for salt
|
// don't use login with alt method
|
||||||
if(!HttpClient.sendGet(ClientCfg.ConfigFile.getVar("StartupPage").asString()+"?cmd=ask&login="+login+"&lg="+ClientCfg.LanguageCode, "", pPM->isVerboseLog()))
|
if (!login.empty())
|
||||||
return "Can't send (error code 60)";
|
|
||||||
|
|
||||||
if(pPM->isVerboseLog()) nlinfo("Sent request for password salt");
|
|
||||||
|
|
||||||
if(!HttpClient.receive(res, pPM->isVerboseLog()))
|
|
||||||
return "Can't receive (error code 61)";
|
|
||||||
|
|
||||||
if(pPM->isVerboseLog()) nlinfo("Received request login check");
|
|
||||||
|
|
||||||
if(res.empty())
|
|
||||||
return "Empty answer from server (error code 62)";
|
|
||||||
|
|
||||||
if(res[0] == '0')
|
|
||||||
{
|
{
|
||||||
// server returns an error
|
// ask server for salt
|
||||||
nlwarning("server error: %s", res.substr(2).c_str());
|
if(!HttpClient.sendGet(ClientCfg.ConfigFile.getVar("StartupPage").asString()+"?cmd=ask&login="+login+"&lg="+ClientCfg.LanguageCode, "", pPM->isVerboseLog()))
|
||||||
return res.substr(2);
|
return "Can't send (error code 60)";
|
||||||
}
|
|
||||||
else if(res[0] == '1')
|
|
||||||
{
|
|
||||||
Salt = res.substr(2);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// server returns ???
|
|
||||||
nlwarning("%s", res.c_str());
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
// send login + crypted password + client app and cp=1 (as crypted password)
|
if(pPM->isVerboseLog()) nlinfo("Sent request for password salt");
|
||||||
if(!HttpClient.connectToLogin())
|
|
||||||
return "Can't connect (error code 63)";
|
|
||||||
|
|
||||||
if(pPM->isVerboseLog()) nlinfo("Connected");
|
if(!HttpClient.receive(res, pPM->isVerboseLog()))
|
||||||
|
return "Can't receive (error code 61)";
|
||||||
|
|
||||||
|
if(pPM->isVerboseLog()) nlinfo("Received request login check");
|
||||||
|
|
||||||
|
if(res.empty())
|
||||||
|
return "Empty answer from server (error code 62)";
|
||||||
|
|
||||||
|
if(res[0] == '0')
|
||||||
|
{
|
||||||
|
// server returns an error
|
||||||
|
nlwarning("server error: %s", res.substr(2).c_str());
|
||||||
|
return res.substr(2);
|
||||||
|
}
|
||||||
|
else if(res[0] == '1')
|
||||||
|
{
|
||||||
|
Salt = res.substr(2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// server returns ???
|
||||||
|
nlwarning("%s", res.c_str());
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
// send login + crypted password + client app and cp=1 (as crypted password)
|
||||||
|
if(!HttpClient.connectToLogin())
|
||||||
|
return "Can't connect (error code 63)";
|
||||||
|
|
||||||
|
if(pPM->isVerboseLog()) nlinfo("Connected");
|
||||||
|
}
|
||||||
|
|
||||||
if (ClientCfg.R2Mode)
|
if (ClientCfg.R2Mode)
|
||||||
{
|
{
|
||||||
// R2 login sequence
|
// R2 login sequence
|
||||||
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))
|
if (!login.empty())
|
||||||
return "Can't send (error code 2)";
|
{
|
||||||
|
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
|
// the response should contains the result code and the cookie value
|
||||||
if(pPM->isVerboseLog()) nlinfo("Sent request login check");
|
if(pPM->isVerboseLog()) nlinfo("Sent request login check");
|
||||||
|
|
Loading…
Reference in a new issue