added support of solt

This commit is contained in:
Andrei Yankovich 2019-06-22 15:52:07 +03:00
parent a54c4a7343
commit 4003999898
2 changed files with 11 additions and 3 deletions

View File

@ -12,8 +12,10 @@
#include "login.h" #include "login.h"
#include "updateplayerdata.h" #include "updateplayerdata.h"
#define SOLT "SNAKE"
namespace ClientProtocol { namespace ClientProtocol {
// TODO // TODO
Command Client::checkCommand(int sig, Command reqCmd, Type type) { Command Client::checkCommand(int sig, Command reqCmd, Type type) {
@ -194,6 +196,13 @@ bool Client::ping() {
return true; return true;
} }
/// Do not change the order of this function,
/// as this may lead to the loss of user accounts.
QByteArray Client::generateHash(const QByteArray& pass) const {
auto passHash = QCryptographicHash::hash(pass, QCryptographicHash::Sha256);
return QCryptographicHash::hash(SOLT + passHash, QCryptographicHash::Sha256);
}
bool Client::login(const QString &gmail, const QByteArray &pass) { bool Client::login(const QString &gmail, const QByteArray &pass) {
if (!pass.size()) { if (!pass.size()) {
return false; return false;
@ -211,9 +220,7 @@ bool Client::login(const QString &gmail, const QByteArray &pass) {
Login login; Login login;
login.setHashPass(QRSAEncryption::encodeS( login.setHashPass(QRSAEncryption::encodeS(generateHash(pass), _rsaKey));
QCryptographicHash::hash(pass, QCryptographicHash::Sha256),
_rsaKey));
login.setGmail(gmail); login.setGmail(gmail);
login.setId(0); login.setId(0);

View File

@ -49,6 +49,7 @@ private:
bool ping(); bool ping();
QByteArray generateHash(const QByteArray &pass) const;
void updateStatuses(Command extCmd, Command cmd, Type type, const QByteArray &obj); void updateStatuses(Command extCmd, Command cmd, Type type, const QByteArray &obj);