mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-17 18:59:09 +00:00
Clean ansi<->unicode from account name code
This commit is contained in:
@ -813,7 +813,7 @@ static void SaveUserPass(LoginDialogParam *pLoginParam, char *password)
|
|||||||
store->SetPassword(pLoginParam->username, plString::Null);
|
store->SetPassword(pLoginParam->username, plString::Null);
|
||||||
}
|
}
|
||||||
|
|
||||||
NetCommSetAccountUsernamePassword(theUser.ToWchar(), pLoginParam->namePassHash);
|
NetCommSetAccountUsernamePassword(theUser, pLoginParam->namePassHash);
|
||||||
|
|
||||||
// FIXME: Real OS detection
|
// FIXME: Real OS detection
|
||||||
NetCommSetAuthTokenAndOS(nil, L"win");
|
NetCommSetAuthTokenAndOS(nil, L"win");
|
||||||
@ -1270,9 +1270,7 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nC
|
|||||||
if (!doIntroDialogs && loginParam.remember) {
|
if (!doIntroDialogs && loginParam.remember) {
|
||||||
ENetError auth;
|
ENetError auth;
|
||||||
|
|
||||||
wchar_t wusername[kMaxAccountNameLength];
|
NetCommSetAccountUsernamePassword(loginParam.username, loginParam.namePassHash);
|
||||||
StrToUnicode(wusername, loginParam.username, arrsize(wusername));
|
|
||||||
NetCommSetAccountUsernamePassword(wusername, loginParam.namePassHash);
|
|
||||||
bool cancelled = AuthenticateNetClientComm(&auth, NULL);
|
bool cancelled = AuthenticateNetClientComm(&auth, NULL);
|
||||||
|
|
||||||
if (IS_NET_ERROR(auth) || cancelled) {
|
if (IS_NET_ERROR(auth) || cancelled) {
|
||||||
|
@ -96,13 +96,13 @@ PyObject* cyAccountManagement::GetPlayerList()
|
|||||||
return pList;
|
return pList;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::wstring cyAccountManagement::GetAccountName()
|
plString cyAccountManagement::GetAccountName()
|
||||||
{
|
{
|
||||||
const NetCommAccount* acct = NetCommGetAccount();
|
const NetCommAccount* acct = NetCommGetAccount();
|
||||||
if (acct)
|
if (acct)
|
||||||
return acct->accountName;
|
return acct->accountName;
|
||||||
else
|
else
|
||||||
return L"";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
void cyAccountManagement::CreatePlayer(const char* playerName, const char* avatar, const char* invitationCode)
|
void cyAccountManagement::CreatePlayer(const char* playerName, const char* avatar, const char* invitationCode)
|
||||||
@ -135,9 +135,7 @@ void cyAccountManagement::UpgradeVisitorToExplorer(unsigned playerId)
|
|||||||
NetCommUpgradeVisitorToExplorer(playerId, nil);
|
NetCommUpgradeVisitorToExplorer(playerId, nil);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cyAccountManagement::ChangePassword(const char* password)
|
void cyAccountManagement::ChangePassword(const plString& password)
|
||||||
{
|
{
|
||||||
wchar_t* wpassword = StrDupToUnicode(password);
|
NetCommChangeMyPassword(password);
|
||||||
NetCommChangeMyPassword(wpassword);
|
|
||||||
free(wpassword);
|
|
||||||
}
|
}
|
||||||
|
@ -50,10 +50,10 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
|
||||||
|
|
||||||
typedef struct _object PyObject;
|
typedef struct _object PyObject;
|
||||||
typedef struct PyMethodDef PyMethodDef;
|
typedef struct PyMethodDef PyMethodDef;
|
||||||
|
class plString;
|
||||||
|
|
||||||
class cyAccountManagement
|
class cyAccountManagement
|
||||||
{
|
{
|
||||||
@ -63,14 +63,14 @@ public:
|
|||||||
|
|
||||||
static bool IsSubscriptionActive();
|
static bool IsSubscriptionActive();
|
||||||
static PyObject* GetPlayerList();
|
static PyObject* GetPlayerList();
|
||||||
static std::wstring GetAccountName();
|
static plString GetAccountName();
|
||||||
static void CreatePlayer(const char* playerName, const char* avatar, const char* invitationCode);
|
static void CreatePlayer(const char* playerName, const char* avatar, const char* invitationCode);
|
||||||
static void CreatePlayerW(const wchar_t* playerName, const wchar_t* avatar, const wchar_t* invitationCode);
|
static void CreatePlayerW(const wchar_t* playerName, const wchar_t* avatar, const wchar_t* invitationCode);
|
||||||
static void DeletePlayer(unsigned playerId);
|
static void DeletePlayer(unsigned playerId);
|
||||||
static void SetActivePlayer(unsigned playerId);
|
static void SetActivePlayer(unsigned playerId);
|
||||||
static bool IsActivePlayerSet();
|
static bool IsActivePlayerSet();
|
||||||
static void UpgradeVisitorToExplorer(unsigned playerId);
|
static void UpgradeVisitorToExplorer(unsigned playerId);
|
||||||
static void ChangePassword(const char* password);
|
static void ChangePassword(const plString& password);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -61,8 +61,7 @@ PYTHON_GLOBAL_METHOD_DEFINITION_NOARGS(PtGetAccountPlayerList, "Returns list of
|
|||||||
|
|
||||||
PYTHON_GLOBAL_METHOD_DEFINITION_NOARGS(PtGetAccountName, "Returns the account name for the current account")
|
PYTHON_GLOBAL_METHOD_DEFINITION_NOARGS(PtGetAccountName, "Returns the account name for the current account")
|
||||||
{
|
{
|
||||||
std::wstring name = cyAccountManagement::GetAccountName();
|
return PyUnicode_FromStringEx(cyAccountManagement::GetAccountName());
|
||||||
return PyUnicode_FromWideChar(name.c_str(), name.length());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PYTHON_GLOBAL_METHOD_DEFINITION(PtCreatePlayer, args, "Params: playerName, avatarShape, invitation\nCreates a new player")
|
PYTHON_GLOBAL_METHOD_DEFINITION(PtCreatePlayer, args, "Params: playerName, avatarShape, invitation\nCreates a new player")
|
||||||
|
@ -155,7 +155,7 @@ void plNetClientMgr::ISendCCRPetition(plCCRPetitionMsg* petMsg)
|
|||||||
info.AddValue( "Petition", "Content", note );
|
info.AddValue( "Petition", "Content", note );
|
||||||
info.AddValue( "Petition", "Title", title );
|
info.AddValue( "Petition", "Title", title );
|
||||||
info.AddValue( "Petition", "Language", plLocalization::GetLanguageName( plLocalization::GetLanguage() ) );
|
info.AddValue( "Petition", "Language", plLocalization::GetLanguageName( plLocalization::GetLanguage() ) );
|
||||||
info.AddValue( "Petition", "AcctName", NetCommGetAccount()->accountNameAnsi );
|
info.AddValue( "Petition", "AcctName", NetCommGetAccount()->accountName.c_str() );
|
||||||
char buffy[20];
|
char buffy[20];
|
||||||
sprintf(buffy, "%u", GetPlayerID());
|
sprintf(buffy, "%u", GetPlayerID());
|
||||||
info.AddValue( "Petition", "PlayerID", buffy );
|
info.AddValue( "Petition", "PlayerID", buffy );
|
||||||
|
@ -116,7 +116,7 @@ static plString s_fileSrvAddr;
|
|||||||
|
|
||||||
static char s_iniServerAddr[256];
|
static char s_iniServerAddr[256];
|
||||||
static char s_iniFileServerAddr[256];
|
static char s_iniFileServerAddr[256];
|
||||||
static wchar_t s_iniAccountUsername[kMaxAccountNameLength];
|
static plString s_iniAccountUsername;
|
||||||
static ShaDigest s_namePassHash;
|
static ShaDigest s_namePassHash;
|
||||||
static wchar_t s_iniAuthToken[kMaxPublisherAuthKeyLength];
|
static wchar_t s_iniAuthToken[kMaxPublisherAuthKeyLength];
|
||||||
static wchar_t s_iniOS[kMaxGTOSIdLength];
|
static wchar_t s_iniOS[kMaxGTOSIdLength];
|
||||||
@ -737,9 +737,7 @@ void NetCommSetAvatarLoaded (bool loaded /* = true */) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void NetCommChangeMyPassword (
|
void NetCommChangeMyPassword (const plString& password) {
|
||||||
const wchar_t password[]
|
|
||||||
) {
|
|
||||||
NetCliAuthAccountChangePasswordRequest(s_account.accountName, password, INetCliAuthChangePasswordCallback, nil);
|
NetCliAuthAccountChangePasswordRequest(s_account.accountName, password, INetCliAuthChangePasswordCallback, nil);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1023,10 +1021,10 @@ void NetCommSetMsgPreHandler (
|
|||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void NetCommSetAccountUsernamePassword (
|
void NetCommSetAccountUsernamePassword (
|
||||||
const wchar_t username[],
|
const plString& username,
|
||||||
const ShaDigest & namePassHash
|
const ShaDigest & namePassHash
|
||||||
) {
|
) {
|
||||||
StrCopy(s_iniAccountUsername, username, arrsize(s_iniAccountUsername));
|
s_iniAccountUsername = username;
|
||||||
memcpy(s_namePassHash, namePassHash, sizeof(ShaDigest));
|
memcpy(s_namePassHash, namePassHash, sizeof(ShaDigest));
|
||||||
|
|
||||||
s_iniReadAccountInfo = false;
|
s_iniReadAccountInfo = false;
|
||||||
@ -1059,16 +1057,7 @@ void NetCommAuthenticate (
|
|||||||
) {
|
) {
|
||||||
s_loginComplete = false;
|
s_loginComplete = false;
|
||||||
|
|
||||||
StrCopy(
|
s_account.accountName = s_iniAccountUsername;
|
||||||
s_account.accountName,
|
|
||||||
s_iniAccountUsername,
|
|
||||||
arrsize(s_account.accountName)
|
|
||||||
);
|
|
||||||
StrToAnsi(
|
|
||||||
s_account.accountNameAnsi,
|
|
||||||
s_iniAccountUsername,
|
|
||||||
arrsize(s_account.accountNameAnsi)
|
|
||||||
);
|
|
||||||
memcpy(s_account.accountNamePassHash, s_namePassHash, sizeof(ShaDigest));
|
memcpy(s_account.accountNamePassHash, s_namePassHash, sizeof(ShaDigest));
|
||||||
|
|
||||||
NetCliAuthLoginRequest(
|
NetCliAuthLoginRequest(
|
||||||
|
@ -80,9 +80,8 @@ struct NetCommPlayer {
|
|||||||
|
|
||||||
struct NetCommAccount {
|
struct NetCommAccount {
|
||||||
plUUID accountUuid;
|
plUUID accountUuid;
|
||||||
wchar_t accountName[kMaxAccountNameLength];
|
plString accountName;
|
||||||
ShaDigest accountNamePassHash;
|
ShaDigest accountNamePassHash;
|
||||||
char accountNameAnsi[kMaxAccountNameLength];
|
|
||||||
unsigned accountFlags;
|
unsigned accountFlags;
|
||||||
unsigned billingType;
|
unsigned billingType;
|
||||||
};
|
};
|
||||||
@ -108,13 +107,13 @@ const ARRAY(NetCommPlayer) & NetCommGetPlayerList ();
|
|||||||
unsigned NetCommGetPlayerCount ();
|
unsigned NetCommGetPlayerCount ();
|
||||||
bool NetCommIsLoginComplete ();
|
bool NetCommIsLoginComplete ();
|
||||||
void NetCommSetReadIniAccountInfo (bool readFromIni);
|
void NetCommSetReadIniAccountInfo (bool readFromIni);
|
||||||
void NetCommSetAccountUsernamePassword (const wchar_t username[], const ShaDigest & namePassHash);
|
void NetCommSetAccountUsernamePassword (const plString& username, const ShaDigest & namePassHash);
|
||||||
void NetCommSetAuthTokenAndOS (wchar_t authToken[], wchar_t os[]);
|
void NetCommSetAuthTokenAndOS (wchar_t authToken[], wchar_t os[]);
|
||||||
ENetError NetCommGetAuthResult ();
|
ENetError NetCommGetAuthResult ();
|
||||||
|
|
||||||
bool NetCommNeedToLoadAvatar ();
|
bool NetCommNeedToLoadAvatar ();
|
||||||
void NetCommSetAvatarLoaded (bool loaded = true);
|
void NetCommSetAvatarLoaded (bool loaded = true);
|
||||||
void NetCommChangeMyPassword (const wchar_t password[]);
|
void NetCommChangeMyPassword (const plString& password);
|
||||||
|
|
||||||
void NetCommStartup ();
|
void NetCommStartup ();
|
||||||
void NetCommShutdown ();
|
void NetCommShutdown ();
|
||||||
|
@ -400,13 +400,13 @@ struct AccountChangePasswordRequestTrans : NetAuthTrans {
|
|||||||
FNetCliAuthAccountChangePasswordRequestCallback m_callback;
|
FNetCliAuthAccountChangePasswordRequestCallback m_callback;
|
||||||
void * m_param;
|
void * m_param;
|
||||||
|
|
||||||
// send
|
// send
|
||||||
wchar_t m_accountName[kMaxAccountNameLength];
|
plString m_accountName;
|
||||||
ShaDigest m_namePassHash;
|
ShaDigest m_namePassHash;
|
||||||
|
|
||||||
AccountChangePasswordRequestTrans (
|
AccountChangePasswordRequestTrans (
|
||||||
const wchar_t accountName[],
|
const plString& accountName,
|
||||||
const wchar_t password[],
|
const plString& password,
|
||||||
FNetCliAuthAccountChangePasswordRequestCallback callback,
|
FNetCliAuthAccountChangePasswordRequestCallback callback,
|
||||||
void * param
|
void * param
|
||||||
);
|
);
|
||||||
@ -1203,7 +1203,7 @@ static bool s_running;
|
|||||||
static CCritSect s_critsect;
|
static CCritSect s_critsect;
|
||||||
static LISTDECL(CliAuConn, link) s_conns;
|
static LISTDECL(CliAuConn, link) s_conns;
|
||||||
static CliAuConn * s_active;
|
static CliAuConn * s_active;
|
||||||
static wchar_t s_accountName[kMaxAccountNameLength];
|
static plString s_accountName;
|
||||||
static ShaDigest s_accountNamePassHash;
|
static ShaDigest s_accountNamePassHash;
|
||||||
static wchar_t s_authToken[kMaxPublisherAuthKeyLength];
|
static wchar_t s_authToken[kMaxPublisherAuthKeyLength];
|
||||||
static wchar_t s_os[kMaxGTOSIdLength];
|
static wchar_t s_os[kMaxGTOSIdLength];
|
||||||
@ -2634,7 +2634,7 @@ bool LoginRequestTrans::Send () {
|
|||||||
uint32_t clientChallenge = 0;
|
uint32_t clientChallenge = 0;
|
||||||
|
|
||||||
// Regex search for primary email domain
|
// Regex search for primary email domain
|
||||||
std::vector<plString> match = plString::FromWchar(s_accountName).RESearch("[^@]+@([^.]+\\.)*([^.]+)\\.[^.]+");
|
std::vector<plString> match = s_accountName.RESearch("[^@]+@([^.]+\\.)*([^.]+)\\.[^.]+");
|
||||||
if (match.empty() || match[2].CompareI("gametap") == 0) {
|
if (match.empty() || match[2].CompareI("gametap") == 0) {
|
||||||
memcpy(challengeHash, s_accountNamePassHash, sizeof(ShaDigest));
|
memcpy(challengeHash, s_accountNamePassHash, sizeof(ShaDigest));
|
||||||
} else {
|
} else {
|
||||||
@ -2651,11 +2651,13 @@ bool LoginRequestTrans::Send () {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
plStringBuffer<uint16_t> accountName = s_accountName.ToUtf16();
|
||||||
|
|
||||||
const uintptr_t msg[] = {
|
const uintptr_t msg[] = {
|
||||||
kCli2Auth_AcctLoginRequest,
|
kCli2Auth_AcctLoginRequest,
|
||||||
m_transId,
|
m_transId,
|
||||||
clientChallenge,
|
clientChallenge,
|
||||||
(uintptr_t) s_accountName,
|
(uintptr_t) accountName.GetData(),
|
||||||
(uintptr_t) &challengeHash,
|
(uintptr_t) &challengeHash,
|
||||||
(uintptr_t) s_authToken,
|
(uintptr_t) s_authToken,
|
||||||
(uintptr_t) s_os,
|
(uintptr_t) s_os,
|
||||||
@ -3164,19 +3166,18 @@ bool SetPlayerRequestTrans::Recv (
|
|||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
AccountChangePasswordRequestTrans::AccountChangePasswordRequestTrans (
|
AccountChangePasswordRequestTrans::AccountChangePasswordRequestTrans (
|
||||||
const wchar_t accountName[],
|
const plString& accountName,
|
||||||
const wchar_t password[],
|
const plString& password,
|
||||||
FNetCliAuthAccountChangePasswordRequestCallback callback,
|
FNetCliAuthAccountChangePasswordRequestCallback callback,
|
||||||
void * param
|
void * param
|
||||||
) : NetAuthTrans(kAccountChangePasswordRequestTrans)
|
) : NetAuthTrans(kAccountChangePasswordRequestTrans)
|
||||||
|
, m_accountName(accountName)
|
||||||
, m_callback(callback)
|
, m_callback(callback)
|
||||||
, m_param(param)
|
, m_param(param)
|
||||||
{
|
{
|
||||||
StrCopy(m_accountName, accountName, arrsize(m_accountName));
|
|
||||||
|
|
||||||
CryptHashPassword(
|
CryptHashPassword(
|
||||||
plString::FromWchar(m_accountName),
|
m_accountName,
|
||||||
plString::FromWchar(password),
|
password,
|
||||||
m_namePassHash
|
m_namePassHash
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -3186,10 +3187,12 @@ bool AccountChangePasswordRequestTrans::Send () {
|
|||||||
if (!AcquireConn())
|
if (!AcquireConn())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
plStringBuffer<uint16_t> accountName = m_accountName.ToUtf16();
|
||||||
|
|
||||||
const uintptr_t msg[] = {
|
const uintptr_t msg[] = {
|
||||||
kCli2Auth_AcctChangePasswordRequest,
|
kCli2Auth_AcctChangePasswordRequest,
|
||||||
m_transId,
|
m_transId,
|
||||||
(uintptr_t) m_accountName,
|
(uintptr_t) accountName.GetData(),
|
||||||
(uintptr_t) &m_namePassHash,
|
(uintptr_t) &m_namePassHash,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -5228,7 +5231,7 @@ void NetCliAuthAccountExistsRequest (
|
|||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void NetCliAuthLoginRequest (
|
void NetCliAuthLoginRequest (
|
||||||
const wchar_t accountName[],
|
const plString& accountName,
|
||||||
const ShaDigest * accountNamePassHash,
|
const ShaDigest * accountNamePassHash,
|
||||||
const wchar_t authToken[],
|
const wchar_t authToken[],
|
||||||
const wchar_t os[],
|
const wchar_t os[],
|
||||||
@ -5236,8 +5239,8 @@ void NetCliAuthLoginRequest (
|
|||||||
void * param
|
void * param
|
||||||
) {
|
) {
|
||||||
// Cache updated login info if provided.
|
// Cache updated login info if provided.
|
||||||
if (accountName)
|
if (!accountName.IsEmpty())
|
||||||
StrCopy(s_accountName, accountName, arrsize(s_accountName));
|
s_accountName = accountName;
|
||||||
if (accountNamePassHash)
|
if (accountNamePassHash)
|
||||||
memcpy(s_accountNamePassHash, *accountNamePassHash, sizeof(ShaDigest));
|
memcpy(s_accountNamePassHash, *accountNamePassHash, sizeof(ShaDigest));
|
||||||
if (authToken)
|
if (authToken)
|
||||||
@ -5437,8 +5440,8 @@ void NetCliAuthGetPublicAgeList (
|
|||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void NetCliAuthAccountChangePasswordRequest (
|
void NetCliAuthAccountChangePasswordRequest (
|
||||||
const wchar_t accountName[],
|
const plString& accountName,
|
||||||
const wchar_t password[],
|
const plString& password,
|
||||||
FNetCliAuthAccountChangePasswordRequestCallback callback,
|
FNetCliAuthAccountChangePasswordRequestCallback callback,
|
||||||
void * param
|
void * param
|
||||||
) {
|
) {
|
||||||
|
@ -135,7 +135,7 @@ typedef void (*FNetCliAuthLoginRequestCallback)(
|
|||||||
unsigned playerCount
|
unsigned playerCount
|
||||||
);
|
);
|
||||||
void NetCliAuthLoginRequest (
|
void NetCliAuthLoginRequest (
|
||||||
const wchar_t accountName[], // nil --> reuse previous acct name
|
const plString& accountName, // nil --> reuse previous acct name
|
||||||
const ShaDigest * accountNamePassHash, // nil --> reuse previous acct pass
|
const ShaDigest * accountNamePassHash, // nil --> reuse previous acct pass
|
||||||
const wchar_t authToken[], // nil --> reuse previous auth token
|
const wchar_t authToken[], // nil --> reuse previous auth token
|
||||||
const wchar_t os[], // nil --> reuse previous os
|
const wchar_t os[], // nil --> reuse previous os
|
||||||
@ -271,8 +271,8 @@ typedef void (*FNetCliAuthAccountChangePasswordRequestCallback)(
|
|||||||
void * param
|
void * param
|
||||||
);
|
);
|
||||||
void NetCliAuthAccountChangePasswordRequest (
|
void NetCliAuthAccountChangePasswordRequest (
|
||||||
const wchar_t accountName[],
|
const plString& accountName,
|
||||||
const wchar_t accountPass[],
|
const plString& accountPass,
|
||||||
FNetCliAuthAccountChangePasswordRequestCallback callback,
|
FNetCliAuthAccountChangePasswordRequestCallback callback,
|
||||||
void * param
|
void * param
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user