Revert "stored user email, token and type in settings #4168"

This reverts commit 319de60286.
This commit is contained in:
XinyuHou 2015-02-05 11:44:31 +00:00
parent f4f7315a54
commit c25b6a8bf6
11 changed files with 31 additions and 74 deletions

View File

@ -91,8 +91,7 @@ HEADERS += src/MainWindow.h \
src/AddClientDialog.h \ src/AddClientDialog.h \
src/CommandProcess.h \ src/CommandProcess.h \
src/LoginWindow.h \ src/LoginWindow.h \
src/LoginAuth.h \ src/LoginAuth.h
src/LoginResult.h
RESOURCES += res/Synergy.qrc RESOURCES += res/Synergy.qrc
RC_FILE = res/win/Synergy.rc RC_FILE = res/win/Synergy.rc
macx { macx {

View File

@ -127,9 +127,6 @@ void AppConfig::loadSettings()
m_AutoConfig = settings().value("autoConfig", true).toBool(); m_AutoConfig = settings().value("autoConfig", true).toBool();
m_ElevateMode = settings().value("elevateMode", false).toBool(); m_ElevateMode = settings().value("elevateMode", false).toBool();
m_AutoConfigPrompted = settings().value("autoConfigPrompted", false).toBool(); m_AutoConfigPrompted = settings().value("autoConfigPrompted", false).toBool();
m_UserEmail = settings().value("userEmail", "").toString();
m_UserToken = settings().value("userToken", "").toString();
m_UserType = settings().value("userType", 0).toInt();
} }
void AppConfig::saveSettings() void AppConfig::saveSettings()
@ -148,9 +145,6 @@ void AppConfig::saveSettings()
settings().setValue("autoConfig", m_AutoConfig); settings().setValue("autoConfig", m_AutoConfig);
settings().setValue("elevateMode", m_ElevateMode); settings().setValue("elevateMode", m_ElevateMode);
settings().setValue("autoConfigPrompted", m_AutoConfigPrompted); settings().setValue("autoConfigPrompted", m_AutoConfigPrompted);
settings().setValue("userEmail", m_UserEmail);
settings().setValue("userToken", m_UserToken);
settings().setValue("userType", m_UserType);
} }
void AppConfig::setCryptoPass(const QString &s) void AppConfig::setCryptoPass(const QString &s)

View File

@ -47,7 +47,6 @@ class AppConfig
friend class SettingsDialog; friend class SettingsDialog;
friend class MainWindow; friend class MainWindow;
friend class SetupWizard; friend class SetupWizard;
friend class LoginWindow;
public: public:
AppConfig(QSettings* settings); AppConfig(QSettings* settings);
@ -73,9 +72,6 @@ class AppConfig
void setAutoConfig(bool autoConfig); void setAutoConfig(bool autoConfig);
bool autoConfigPrompted() { return m_AutoConfigPrompted; } bool autoConfigPrompted() { return m_AutoConfigPrompted; }
void setAutoConfigPrompted(bool prompted); void setAutoConfigPrompted(bool prompted);
const QString& userEmail() const { return m_UserEmail; }
const QString& userToken() const { return m_UserToken; }
const int userType() const { return m_UserType; }
QString synergysName() const { return m_SynergysName; } QString synergysName() const { return m_SynergysName; }
QString synergycName() const { return m_SynergycName; } QString synergycName() const { return m_SynergycName; }
@ -99,9 +95,7 @@ class AppConfig
void setLanguage(const QString language) { m_Language = language; } void setLanguage(const QString language) { m_Language = language; }
void setStartedBefore(bool b) { m_StartedBefore = b; } void setStartedBefore(bool b) { m_StartedBefore = b; }
void setElevateMode(bool b) { m_ElevateMode = b; } void setElevateMode(bool b) { m_ElevateMode = b; }
void setUserEmail(const QString& e) { m_UserEmail = e; }
void setUserToken(const QString& t) { m_UserToken = t; }
void setUserType(int t) { m_UserType = t; }
void loadSettings(); void loadSettings();
void saveSettings(); void saveSettings();
@ -124,9 +118,6 @@ class AppConfig
bool m_AutoConfig; bool m_AutoConfig;
bool m_ElevateMode; bool m_ElevateMode;
bool m_AutoConfigPrompted; bool m_AutoConfigPrompted;
QString m_UserEmail;
QString m_UserToken;
int m_UserType;
static const char m_SynergysName[]; static const char m_SynergysName[];
static const char m_SynergycName[]; static const char m_SynergycName[];

View File

@ -1,9 +1,6 @@
#include "LoginAuth.h" #include "LoginAuth.h"
#include "LoginWindow.h" #include "LoginWindow.h"
#include "AppConfig.h"
#include "QUtility.h"
#include "LoginResult.h"
#include <QProcess> #include <QProcess>
#include <QCoreApplication> #include <QCoreApplication>
@ -96,3 +93,10 @@ QString LoginAuth::request(const QString& email, const QString& password)
return out; return out;
} }
QString LoginAuth::hash(const QString& string)
{
QByteArray data = string.toUtf8();
QByteArray hash = QCryptographicHash::hash(data, QCryptographicHash::Md5);
return hash.toHex();
}

View File

@ -5,7 +5,18 @@
#include <QObject> #include <QObject>
class LoginWindow; class LoginWindow;
class AppConfig;
enum qUserType {
Student,
Home,
Professional,
Error,
ExceptionError,
InvalidEmailPassword,
ServerResponseError,
Unknown
};
class LoginAuth : public QObject class LoginAuth : public QObject
{ {
@ -25,6 +36,7 @@ signals:
private: private:
QString request(const QString& email, const QString& password); QString request(const QString& email, const QString& password);
QString hash(const QString& string);
private: private:
QString m_Email; QString m_Email;

View File

@ -1,15 +0,0 @@
#ifndef LOGINRESULT_H
#define LOGINRESULT_H
enum qLoginResult {
Unknown,
Student,
Home,
Professional,
Error,
ExceptionError,
InvalidEmailPassword,
ServerResponseError
};
#endif // LOGINRESULT_H

View File

@ -4,8 +4,6 @@
#include "MainWindow.h" #include "MainWindow.h"
#include "SetupWizard.h" #include "SetupWizard.h"
#include "LoginAuth.h" #include "LoginAuth.h"
#include "LoginResult.h"
#include "QUtility.h"
#include <QMessageBox> #include <QMessageBox>
#include <QCloseEvent> #include <QCloseEvent>
@ -21,12 +19,11 @@ LoginWindow::LoginWindow(
m_pSetupWizard(setupWizard), m_pSetupWizard(setupWizard),
m_WizardShouldRun(wizardShouldRun), m_WizardShouldRun(wizardShouldRun),
m_pLoginAuth(NULL), m_pLoginAuth(NULL),
m_LoginResult(Unknown), m_LoginResult(Unknown)
m_AppConfig(m_pMainWindow->appConfig())
{ {
setupUi(this); setupUi(this);
m_pLineEditEmail->setText(m_AppConfig.userEmail());
} }
LoginWindow::~LoginWindow() LoginWindow::~LoginWindow()
@ -72,17 +69,6 @@ void LoginWindow::showNext()
} }
else { else {
m_pMainWindow->setLoginResult(m_LoginResult); m_pMainWindow->setLoginResult(m_LoginResult);
if (!m_pLineEditEmail->text().isEmpty()) {
m_AppConfig.setUserEmail(m_pLineEditEmail->text());
if (m_LoginResult != Unknown) {
QString mac = getFirstMacAddress();
QString hashSrc = m_pLineEditEmail->text() + mac;
QString hashResult = hash(hashSrc);
m_AppConfig.setUserToken(hashResult);
m_AppConfig.setUserType(m_LoginResult);
}
}
m_pMainWindow->show(); m_pMainWindow->show();
} }
} }

View File

@ -8,7 +8,6 @@
class MainWindow; class MainWindow;
class SetupWizard; class SetupWizard;
class LoginAuth; class LoginAuth;
class AppConfig;
class LoginWindow : public QMainWindow, public Ui::LoginWindow class LoginWindow : public QMainWindow, public Ui::LoginWindow
{ {
@ -41,7 +40,6 @@ private:
LoginAuth* m_pLoginAuth; LoginAuth* m_pLoginAuth;
int m_LoginResult; int m_LoginResult;
QString m_Error; QString m_Error;
AppConfig& m_AppConfig;
}; };

View File

@ -29,7 +29,6 @@
#include "DataDownloader.h" #include "DataDownloader.h"
#include "CommandProcess.h" #include "CommandProcess.h"
#include "LoginAuth.h" #include "LoginAuth.h"
#include "LoginResult.h"
#include <QtCore> #include <QtCore>
#include <QtGui> #include <QtGui>

View File

@ -113,7 +113,6 @@ class MainWindow : public QMainWindow, public Ui::MainWindowBase
void serverDetected(const QString name); void serverDetected(const QString name);
int checkWinArch(); int checkWinArch();
void setLoginResult(int result); void setLoginResult(int result);
AppConfig& appConfig() { return m_AppConfig; }
public slots: public slots:
void appendLogRaw(const QString& text); void appendLogRaw(const QString& text);
@ -141,6 +140,7 @@ class MainWindow : public QMainWindow, public Ui::MainWindowBase
protected: protected:
QSettings& settings() { return m_Settings; } QSettings& settings() { return m_Settings; }
AppConfig& appConfig() { return m_AppConfig; }
QProcess*& synergyProcess() { return m_pSynergy; } QProcess*& synergyProcess() { return m_pSynergy; }
void setSynergyProcess(QProcess* p) { m_pSynergy = p; } void setSynergyProcess(QProcess* p) { m_pSynergy = p; }
void initConnections(); void initConnections();

View File

@ -24,8 +24,6 @@
#include "AppConfig.h" #include "AppConfig.h"
#include "SetupWizard.h" #include "SetupWizard.h"
#include "LoginWindow.h" #include "LoginWindow.h"
#include "QUtility.h"
#include "LoginResult.h"
#include <QtCore> #include <QtCore>
#include <QtGui> #include <QtGui>
@ -95,22 +93,13 @@ int main(int argc, char* argv[])
MainWindow mainWindow(settings, appConfig); MainWindow mainWindow(settings, appConfig);
SetupWizard setupWizard(mainWindow, true); SetupWizard setupWizard(mainWindow, true);
LoginWindow loginWindow( LoginWindow loginWindow(
&mainWindow, &mainWindow,
&setupWizard, &setupWizard,
appConfig.wizardShouldRun()); appConfig.wizardShouldRun());
QString email = appConfig.userEmail();
QString mac = getFirstMacAddress();
QString hashSrc = email + mac;
QString hashResult = hash(hashSrc);
if (hashResult == appConfig.userToken()) {
mainWindow.setLoginResult(appConfig.userType());
mainWindow.show();
}
else {
loginWindow.show(); loginWindow.show();
}
return app.exec(); return app.exec();
} }