mirror of
https://github.com/overte-org/overte.git
synced 2025-04-14 00:47:33 +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";
|
||||
QDir applicationDir(applicationPath);
|
||||
QFile configFile(applicationDir.filePath(APPLICATION_CONFIG_FILENAME));
|
||||
bool isConfigFileValid = false;
|
||||
QString configFileName = applicationDir.filePath(APPLICATION_CONFIG_FILENAME);
|
||||
QFile configFile(configFileName);
|
||||
QString launcherPath;
|
||||
|
||||
if (configFile.exists()) {
|
||||
if (!configFile.open(QIODevice::ReadOnly)) {
|
||||
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();
|
||||
} else {
|
||||
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()) {
|
||||
isConfigFileValid = true;
|
||||
if (!parser.isSet(noLauncherOption)) {
|
||||
qDebug() << "Found a launcherPath in application config. Starting launcher.";
|
||||
QProcess launcher;
|
||||
|
@ -402,15 +403,16 @@ int main(int argc, const char* argv[]) {
|
|||
|
||||
printSystemInformation();
|
||||
|
||||
if (isConfigFileValid || parser.isSet(responseTokensOption)) {
|
||||
if (!launcherPath.isEmpty() || parser.isSet(responseTokensOption)) {
|
||||
auto accountManager = DependencyManager::get<AccountManager>();
|
||||
if (!accountManager.isNull()) {
|
||||
if (!launcherPath.isEmpty()) {
|
||||
accountManager->setConfigFileURL(configFileName);
|
||||
}
|
||||
if (parser.isSet(responseTokensOption)) {
|
||||
QString tokens = QString(parser.value(responseTokensOption));
|
||||
accountManager->setAccessTokens(tokens);
|
||||
} else if (isConfigFileValid) {
|
||||
accountManager->setConfigFileURL(configFile.fileName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -674,7 +674,7 @@ void AccountManager::setAccessTokens(const QString& response) {
|
|||
emit loginComplete(rootURL);
|
||||
|
||||
persistAccountToFile();
|
||||
|
||||
saveLoginStatus(true);
|
||||
requestProfile();
|
||||
}
|
||||
} else {
|
||||
|
@ -931,8 +931,8 @@ void AccountManager::setLimitedCommerce(bool isLimited) {
|
|||
}
|
||||
|
||||
void AccountManager::saveLoginStatus(bool isLoggedIn) {
|
||||
if (_configFileURL.isValid()) {
|
||||
QFile configFile(_configFileURL.toString());
|
||||
if (!_configFileURL.isEmpty()) {
|
||||
QFile configFile(_configFileURL);
|
||||
configFile.open(QIODevice::ReadOnly | QIODevice::Text);
|
||||
QJsonParseError error;
|
||||
QJsonDocument jsonDocument = QJsonDocument::fromJson(configFile.readAll(), &error);
|
||||
|
@ -940,12 +940,14 @@ void AccountManager::saveLoginStatus(bool isLoggedIn) {
|
|||
QString launcherPath;
|
||||
if (error.error == QJsonParseError::NoError) {
|
||||
QJsonObject rootObject = jsonDocument.object();
|
||||
if (rootObject.contains("launcherPath")) {
|
||||
launcherPath = rootObject["launcherPath"].toString();
|
||||
}
|
||||
if (rootObject.contains("loggedIn")) {
|
||||
rootObject["loggedIn"] = isLoggedIn;
|
||||
}
|
||||
if (rootObject.contains("laucherPath")) {
|
||||
launcherPath = rootObject["launcherPath"].isString();
|
||||
}
|
||||
jsonDocument = QJsonDocument(rootObject);
|
||||
|
||||
}
|
||||
configFile.open(QFile::WriteOnly | QFile::Text | QFile::Truncate);
|
||||
configFile.write(jsonDocument.toJson());
|
||||
|
|
|
@ -103,7 +103,7 @@ public:
|
|||
void setLimitedCommerce(bool isLimited);
|
||||
|
||||
void setAccessTokens(const QString& response);
|
||||
void setConfigFileURL(const QUrl& fileURL) { _configFileURL = fileURL; }
|
||||
void setConfigFileURL(const QString& fileURL) { _configFileURL = fileURL; }
|
||||
void saveLoginStatus(bool isLoggedIn);
|
||||
|
||||
public slots:
|
||||
|
@ -166,7 +166,7 @@ private:
|
|||
QUuid _sessionID { QUuid::createUuid() };
|
||||
|
||||
bool _limitedCommerce { false };
|
||||
QUrl _configFileURL;
|
||||
QString _configFileURL;
|
||||
};
|
||||
|
||||
#endif // hifi_AccountManager_h
|
||||
|
|
Loading…
Reference in a new issue