Commit to resolve requests made by @Daenyth discussed after the commit.
See https://github.com/Cockatrice/Cockatrice/pull/1340 for details.
This commit is contained in:
parent
62dc3a7ca3
commit
94942e1a92
5 changed files with 12 additions and 10 deletions
|
@ -35,7 +35,6 @@
|
|||
#include "QtNetwork/QNetworkInterface"
|
||||
#include <QCryptographicHash>
|
||||
|
||||
|
||||
#include "main.h"
|
||||
#include "window_main.h"
|
||||
#include "dlg_settings.h"
|
||||
|
@ -100,7 +99,7 @@ bool settingsValid()
|
|||
!settingsCache->getPicsPath().isEmpty();
|
||||
}
|
||||
|
||||
void generateClientID()
|
||||
QString const generateClientID()
|
||||
{
|
||||
QString macList;
|
||||
foreach(QNetworkInterface interface, QNetworkInterface::allInterfaces())
|
||||
|
@ -110,7 +109,7 @@ void generateClientID()
|
|||
macList += interface.hardwareAddress() + ".";
|
||||
}
|
||||
QString strClientID = QCryptographicHash::hash(macList.toUtf8(), QCryptographicHash::Sha1).toHex().right(15);
|
||||
settingsCache->setClientID(strClientID);
|
||||
return strClientID;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
|
@ -220,7 +219,7 @@ int main(int argc, char *argv[])
|
|||
QIcon icon(":/resources/appicon.svg");
|
||||
ui.setWindowIcon(icon);
|
||||
|
||||
generateClientID(); //generate the users client id
|
||||
settingsCache->setClientID(generateClientID());
|
||||
qDebug() << "ClientID In Cache: " << settingsCache->getClientID();
|
||||
|
||||
ui.showMaximized();
|
||||
|
|
|
@ -7,14 +7,14 @@ class QSystemTrayIcon;
|
|||
class SoundEngine;
|
||||
|
||||
extern CardDatabase *db;
|
||||
|
||||
extern QSystemTrayIcon *trayIcon;
|
||||
extern QTranslator *translator;
|
||||
extern const QString translationPrefix;
|
||||
extern QString translationPath;
|
||||
|
||||
void installNewTranslator();
|
||||
void generateClientID();
|
||||
|
||||
QString const generateClientID();
|
||||
|
||||
bool settingsValid();
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ message Response {
|
|||
RespActivationAccepted = 31; // Server accepted a reg user activation token
|
||||
RespActivationFailed = 32; // Server didn't accept a reg user activation token
|
||||
RespRegistrationAcceptedNeedsActivation = 33; // Server accepted cient registration, but it will need token activation
|
||||
RespClientIDRequired = 34; // Server require's client to generate and send its client id before allowing access
|
||||
RespClientIDRequired = 34; // Server requires client to generate and send its client id before allowing access
|
||||
}
|
||||
enum ResponseType {
|
||||
JOIN_ROOM = 1000;
|
||||
|
|
|
@ -170,7 +170,6 @@ AuthenticationResult Server::loginUser(Server_ProtocolHandler *session, QString
|
|||
event.mutable_user_info()->CopyFrom(session->copyUserInfo(true, true, true));
|
||||
locker.unlock();
|
||||
|
||||
// check if client id exists (older client compatibility)
|
||||
if (clientid.isEmpty()){
|
||||
// client id is empty, either out dated client or client has been modified
|
||||
}
|
||||
|
|
|
@ -381,12 +381,16 @@ Response::ResponseCode Server_ProtocolHandler::cmdPing(const Command_Ping & /*cm
|
|||
Response::ResponseCode Server_ProtocolHandler::cmdLogin(const Command_Login &cmd, ResponseContainer &rc)
|
||||
{
|
||||
QString userName = QString::fromStdString(cmd.user_name()).simplified();
|
||||
QString clientid = QString::fromStdString(cmd.clientid()).simplified();
|
||||
QString clientId = QString::fromStdString(cmd.clientid()).simplified();
|
||||
|
||||
if (userName.isEmpty() || (userInfo != 0))
|
||||
return Response::RespContextError;
|
||||
if (clientId.isEmpty())
|
||||
return Response::RespContextError;
|
||||
|
||||
QString reasonStr;
|
||||
int banSecondsLeft = 0;
|
||||
AuthenticationResult res = server->loginUser(this, userName, QString::fromStdString(cmd.password()), reasonStr, banSecondsLeft, clientid);
|
||||
AuthenticationResult res = server->loginUser(this, userName, QString::fromStdString(cmd.password()), reasonStr, banSecondsLeft, clientId);
|
||||
switch (res) {
|
||||
case UserIsBanned: {
|
||||
Response_Login *re = new Response_Login;
|
||||
|
|
Loading…
Reference in a new issue