mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 05:58:27 +02:00
Fix logout
This commit is contained in:
parent
206e353264
commit
6d824ff22d
3 changed files with 20 additions and 16 deletions
|
@ -122,8 +122,10 @@ int main(int argc, const char* argv[]) {
|
||||||
|
|
||||||
static const QString APPLICATION_CONFIG_FILENAME = "config.json";
|
static const QString APPLICATION_CONFIG_FILENAME = "config.json";
|
||||||
QDir applicationDir(applicationPath);
|
QDir applicationDir(applicationPath);
|
||||||
QFile configFile(applicationDir.filePath(APPLICATION_CONFIG_FILENAME));
|
QString configFileName = applicationDir.filePath(APPLICATION_CONFIG_FILENAME);
|
||||||
bool isConfigFileValid = false;
|
QFile configFile(configFileName);
|
||||||
|
QString launcherPath;
|
||||||
|
|
||||||
if (configFile.exists()) {
|
if (configFile.exists()) {
|
||||||
if (!configFile.open(QIODevice::ReadOnly)) {
|
if (!configFile.open(QIODevice::ReadOnly)) {
|
||||||
qWarning() << "Found application config, but could not open it";
|
qWarning() << "Found application config, but could not open it";
|
||||||
|
@ -136,9 +138,8 @@ int main(int argc, const char* argv[]) {
|
||||||
qWarning() << "Found application config, but could not parse it: " << error.errorString();
|
qWarning() << "Found application config, but could not parse it: " << error.errorString();
|
||||||
} else {
|
} else {
|
||||||
static const QString LAUNCHER_PATH_KEY = "launcherPath";
|
static const QString LAUNCHER_PATH_KEY = "launcherPath";
|
||||||
QString launcherPath = doc.object()[LAUNCHER_PATH_KEY].toString();
|
launcherPath = doc.object()[LAUNCHER_PATH_KEY].toString();
|
||||||
if (!launcherPath.isEmpty()) {
|
if (!launcherPath.isEmpty()) {
|
||||||
isConfigFileValid = true;
|
|
||||||
if (!parser.isSet(noLauncherOption)) {
|
if (!parser.isSet(noLauncherOption)) {
|
||||||
qDebug() << "Found a launcherPath in application config. Starting launcher.";
|
qDebug() << "Found a launcherPath in application config. Starting launcher.";
|
||||||
QProcess launcher;
|
QProcess launcher;
|
||||||
|
@ -402,15 +403,16 @@ int main(int argc, const char* argv[]) {
|
||||||
|
|
||||||
printSystemInformation();
|
printSystemInformation();
|
||||||
|
|
||||||
if (isConfigFileValid || parser.isSet(responseTokensOption)) {
|
if (!launcherPath.isEmpty() || parser.isSet(responseTokensOption)) {
|
||||||
auto accountManager = DependencyManager::get<AccountManager>();
|
auto accountManager = DependencyManager::get<AccountManager>();
|
||||||
if (!accountManager.isNull()) {
|
if (!accountManager.isNull()) {
|
||||||
|
if (!launcherPath.isEmpty()) {
|
||||||
|
accountManager->setConfigFileURL(configFileName);
|
||||||
|
}
|
||||||
if (parser.isSet(responseTokensOption)) {
|
if (parser.isSet(responseTokensOption)) {
|
||||||
QString tokens = QString(parser.value(responseTokensOption));
|
QString tokens = QString(parser.value(responseTokensOption));
|
||||||
accountManager->setAccessTokens(tokens);
|
accountManager->setAccessTokens(tokens);
|
||||||
} else if (isConfigFileValid) {
|
}
|
||||||
accountManager->setConfigFileURL(configFile.fileName());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -674,7 +674,7 @@ void AccountManager::setAccessTokens(const QString& response) {
|
||||||
emit loginComplete(rootURL);
|
emit loginComplete(rootURL);
|
||||||
|
|
||||||
persistAccountToFile();
|
persistAccountToFile();
|
||||||
|
saveLoginStatus(true);
|
||||||
requestProfile();
|
requestProfile();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -931,8 +931,8 @@ void AccountManager::setLimitedCommerce(bool isLimited) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccountManager::saveLoginStatus(bool isLoggedIn) {
|
void AccountManager::saveLoginStatus(bool isLoggedIn) {
|
||||||
if (_configFileURL.isValid()) {
|
if (!_configFileURL.isEmpty()) {
|
||||||
QFile configFile(_configFileURL.toString());
|
QFile configFile(_configFileURL);
|
||||||
configFile.open(QIODevice::ReadOnly | QIODevice::Text);
|
configFile.open(QIODevice::ReadOnly | QIODevice::Text);
|
||||||
QJsonParseError error;
|
QJsonParseError error;
|
||||||
QJsonDocument jsonDocument = QJsonDocument::fromJson(configFile.readAll(), &error);
|
QJsonDocument jsonDocument = QJsonDocument::fromJson(configFile.readAll(), &error);
|
||||||
|
@ -940,12 +940,14 @@ void AccountManager::saveLoginStatus(bool isLoggedIn) {
|
||||||
QString launcherPath;
|
QString launcherPath;
|
||||||
if (error.error == QJsonParseError::NoError) {
|
if (error.error == QJsonParseError::NoError) {
|
||||||
QJsonObject rootObject = jsonDocument.object();
|
QJsonObject rootObject = jsonDocument.object();
|
||||||
|
if (rootObject.contains("launcherPath")) {
|
||||||
|
launcherPath = rootObject["launcherPath"].toString();
|
||||||
|
}
|
||||||
if (rootObject.contains("loggedIn")) {
|
if (rootObject.contains("loggedIn")) {
|
||||||
rootObject["loggedIn"] = isLoggedIn;
|
rootObject["loggedIn"] = isLoggedIn;
|
||||||
}
|
}
|
||||||
if (rootObject.contains("laucherPath")) {
|
jsonDocument = QJsonDocument(rootObject);
|
||||||
launcherPath = rootObject["launcherPath"].isString();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
configFile.open(QFile::WriteOnly | QFile::Text | QFile::Truncate);
|
configFile.open(QFile::WriteOnly | QFile::Text | QFile::Truncate);
|
||||||
configFile.write(jsonDocument.toJson());
|
configFile.write(jsonDocument.toJson());
|
||||||
|
|
|
@ -103,7 +103,7 @@ public:
|
||||||
void setLimitedCommerce(bool isLimited);
|
void setLimitedCommerce(bool isLimited);
|
||||||
|
|
||||||
void setAccessTokens(const QString& response);
|
void setAccessTokens(const QString& response);
|
||||||
void setConfigFileURL(const QUrl& fileURL) { _configFileURL = fileURL; }
|
void setConfigFileURL(const QString& fileURL) { _configFileURL = fileURL; }
|
||||||
void saveLoginStatus(bool isLoggedIn);
|
void saveLoginStatus(bool isLoggedIn);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
@ -166,7 +166,7 @@ private:
|
||||||
QUuid _sessionID { QUuid::createUuid() };
|
QUuid _sessionID { QUuid::createUuid() };
|
||||||
|
|
||||||
bool _limitedCommerce { false };
|
bool _limitedCommerce { false };
|
||||||
QUrl _configFileURL;
|
QString _configFileURL;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_AccountManager_h
|
#endif // hifi_AccountManager_h
|
||||||
|
|
Loading…
Reference in a new issue