void AuthSession::HandleClientAuthentication(WorldPacket& packet) { quint32 bufferSize; packet >> bufferSize; QByteArray buffer; buffer.resize(bufferSize); packet.ReadRawBytes(buffer.data(), buffer.size()); WorldPacket decrypted(0, sCryptographyMgr->Decrypt(buffer)); quint64 salt; decrypted >> salt; m_username = decrypted.ReadString(); QString password = decrypted.ReadString(); QSqlQuery result = sAuthDatabase->Query(SELECT_ACCOUNT_BY_USERNAME, QVariantList() << m_username); if (!result.first()) { SendLoginErrorResult(LOGIN_RESULT_ERROR_INVALID_LOGIN); return; } QString hashPassword = result.value("hash_password").toString(); if (Utils::HashPassword(m_username, password) != hashPassword) { SendLoginErrorResult(LOGIN_RESULT_ERROR_INVALID_LOGIN); return; } m_accountId = result.value("account_id").toUInt(); WorldPacket data(SMSG_CLIENT_AUTH_RESULT); data << quint8(LOGIN_RESULT_SUCCESS); data << quint8(0); // m_activateSteamLinkHint (bool) data << quint8(1); // hasAccountInformations data << int(COMMUNITY_FR); // Community data << quint8(0); // hasAdminInformations? SendPacket(data); }
void WorldSession::HandleClientAuthentication(WorldPacket& packet) { quint32 bufferSize; packet >> bufferSize; QByteArray buffer; buffer.resize(bufferSize); packet.ReadRawBytes(buffer.data(), buffer.size()); WorldPacket decrypted(0, Cryptography::Instance()->Decrypt(buffer)); quint64 rsaVerification; decrypted >> rsaVerification; QString account = decrypted.ReadString(); QString password = decrypted.ReadString(); QSqlQuery result = Database::Auth()->Query(SELECT_ACCOUNT_BY_USERNAME, QVariantList() << account); if (!result.first()) { SendLoginErrorResult(LOGIN_RESULT_INVALID_LOGIN); return; } QSqlRecord fields = result.record(); QString hashPassword = result.value(fields.indexOf("hash_password")).toString(); if (Utils::HashPassword(account, password) != hashPassword) { SendLoginErrorResult(LOGIN_RESULT_INVALID_LOGIN); return; } m_accountInfos.id = result.value(fields.indexOf("account_id")).toULongLong(); m_accountInfos.username = result.value(fields.indexOf("username")).toString(); m_accountInfos.pseudo = result.value(fields.indexOf("pseudo")).toString(); m_accountInfos.gmLevel = (quint8)result.value(fields.indexOf("username")).toUInt(); m_accountInfos.subscriptionTime = result.value(fields.indexOf("subscription_time")).toUInt(); // Send opcode 2 (connection retry ticket, not implemented) WorldPacket data2(SMSG_CONNECTION_RETRY_TICKET); SendPacket(data2); WorldPacket data(SMSG_CLIENT_AUTH_RESULT); data << quint8(LOGIN_RESULT_SUCCESS); data.StartBlock<quint16>(); { data << quint8(1); { data << quint8(0); data << quint32(6); data << quint8(0); data << quint64(result.value(fields.indexOf("account_id")).toULongLong()); data << quint32(1); // m_subscriptionLevel data << quint32(0); // antiAddictionLevel data << quint64(m_accountInfos.subscriptionTime); // Admin rights ? for (quint8 i = 0; i <= 75; ++i) data << quint32(0); data.WriteString(m_accountInfos.pseudo); data << quint32(0); // m_accountCommunity ID, see Wl.java for IDs data << quint16(0); // size of hdv, see bOE.java something with m_accountCommunity and check TS.java } } data.EndBlock<quint16>(); SendPacket(data); SendWorldSelectResult(); }