mirror of
https://github.com/QuasarApp/Snake.git
synced 2025-05-08 15:39:45 +00:00
added support of solt
This commit is contained in:
parent
a54c4a7343
commit
4003999898
SnakeServer/ClientProtocol
@ -12,8 +12,10 @@
|
||||
#include "login.h"
|
||||
#include "updateplayerdata.h"
|
||||
|
||||
#define SOLT "SNAKE"
|
||||
namespace ClientProtocol {
|
||||
|
||||
|
||||
// TODO
|
||||
Command Client::checkCommand(int sig, Command reqCmd, Type type) {
|
||||
|
||||
@ -194,6 +196,13 @@ bool Client::ping() {
|
||||
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) {
|
||||
if (!pass.size()) {
|
||||
return false;
|
||||
@ -211,9 +220,7 @@ bool Client::login(const QString &gmail, const QByteArray &pass) {
|
||||
|
||||
Login login;
|
||||
|
||||
login.setHashPass(QRSAEncryption::encodeS(
|
||||
QCryptographicHash::hash(pass, QCryptographicHash::Sha256),
|
||||
_rsaKey));
|
||||
login.setHashPass(QRSAEncryption::encodeS(generateHash(pass), _rsaKey));
|
||||
login.setGmail(gmail);
|
||||
login.setId(0);
|
||||
|
||||
|
@ -49,6 +49,7 @@ private:
|
||||
|
||||
bool ping();
|
||||
|
||||
QByteArray generateHash(const QByteArray &pass) const;
|
||||
|
||||
void updateStatuses(Command extCmd, Command cmd, Type type, const QByteArray &obj);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user