mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-20 16:08:44 +00:00
Fixed: Implement alternate login system with LoginCustomParameters
This commit is contained in:
parent
840f5b7c61
commit
10f56871e6
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;
|
||||||
|
@ -247,6 +247,8 @@ void CLoginStateMachine::run()
|
||||||
if (!ClientCfg.TestBrowser)
|
if (!ClientCfg.TestBrowser)
|
||||||
{
|
{
|
||||||
if (LoginLogin.empty())
|
if (LoginLogin.empty())
|
||||||
|
{
|
||||||
|
if (LoginCustomParameters.empty())
|
||||||
{
|
{
|
||||||
// standard procedure
|
// standard procedure
|
||||||
SM_BEGIN_EVENT_TABLE
|
SM_BEGIN_EVENT_TABLE
|
||||||
|
@ -256,6 +258,16 @@ void CLoginStateMachine::run()
|
||||||
SM_END_EVENT_TABLE
|
SM_END_EVENT_TABLE
|
||||||
}
|
}
|
||||||
else
|
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
|
// login 2, bypass the login screen
|
||||||
SM_BEGIN_EVENT_TABLE
|
SM_BEGIN_EVENT_TABLE
|
||||||
|
@ -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,6 +2781,9 @@ string checkLogin(const string &login, const string &password, const string &cli
|
||||||
|
|
||||||
string res;
|
string res;
|
||||||
|
|
||||||
|
// don't use login with alt method
|
||||||
|
if (!login.empty())
|
||||||
|
{
|
||||||
// ask server for salt
|
// ask server for salt
|
||||||
if(!HttpClient.sendGet(ClientCfg.ConfigFile.getVar("StartupPage").asString()+"?cmd=ask&login="+login+"&lg="+ClientCfg.LanguageCode, "", pPM->isVerboseLog()))
|
if(!HttpClient.sendGet(ClientCfg.ConfigFile.getVar("StartupPage").asString()+"?cmd=ask&login="+login+"&lg="+ClientCfg.LanguageCode, "", pPM->isVerboseLog()))
|
||||||
return "Can't send (error code 60)";
|
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)";
|
return "Can't connect (error code 63)";
|
||||||
|
|
||||||
if(pPM->isVerboseLog()) nlinfo("Connected");
|
if(pPM->isVerboseLog()) nlinfo("Connected");
|
||||||
|
}
|
||||||
|
|
||||||
if (ClientCfg.R2Mode)
|
if (ClientCfg.R2Mode)
|
||||||
{
|
{
|
||||||
// R2 login sequence
|
// R2 login sequence
|
||||||
|
|
||||||
|
if (!login.empty())
|
||||||
|
{
|
||||||
std::string cryptedPassword = CCrypt::crypt(password, Salt);
|
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(!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)";
|
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