mirror of
https://github.com/overte-org/overte.git
synced 2025-04-08 04:34:38 +02:00
Fix connection issue syncing two AccountManagers
This commit is contained in:
parent
ec838b1417
commit
a767540b76
3 changed files with 29 additions and 2 deletions
|
@ -22,9 +22,21 @@ AndroidHelper::~AndroidHelper() {
|
|||
}
|
||||
|
||||
void AndroidHelper::init() {
|
||||
qDebug() << "[LOGIN] AndroidHelper::init";
|
||||
workerThread.start();
|
||||
_accountManager = DependencyManager::get<AccountManager>();
|
||||
_accountManager = QSharedPointer<AccountManager>(new AccountManager, &QObject::deleteLater);
|
||||
_accountManager->setIsAgent(true);
|
||||
_accountManager->setAuthURL(NetworkingConstants::METAVERSE_SERVER_URL());
|
||||
_accountManager->setSessionID(DependencyManager::get<AccountManager>()->getSessionID());
|
||||
|
||||
connect(_accountManager.data(), &AccountManager::loginComplete, [](const QUrl& authURL) {
|
||||
DependencyManager::get<AccountManager>()->setAccountInfo(AndroidHelper::instance().getAccountManager()->getAccountInfo());
|
||||
DependencyManager::get<AccountManager>()->setAuthURL(authURL);
|
||||
});
|
||||
|
||||
connect(_accountManager.data(), &AccountManager::logoutComplete, [] () {
|
||||
DependencyManager::get<AccountManager>()->logout();
|
||||
});
|
||||
|
||||
_accountManager->moveToThread(&workerThread);
|
||||
}
|
||||
|
||||
|
|
|
@ -453,6 +453,20 @@ void AccountManager::removeAccountFromFile() {
|
|||
<< "from settings file.";
|
||||
}
|
||||
|
||||
void AccountManager::setAccountInfo(const DataServerAccountInfo &newAccountInfo) {
|
||||
_accountInfo = newAccountInfo;
|
||||
_pendingPrivateKey.clear();
|
||||
if (_isAgent && !_accountInfo.getAccessToken().token.isEmpty() && !_accountInfo.hasProfile()) {
|
||||
// we are missing profile information, request it now
|
||||
requestProfile();
|
||||
}
|
||||
|
||||
// prepare to refresh our token if it is about to expire
|
||||
if (needsToRefreshToken()) {
|
||||
refreshAccessToken();
|
||||
}
|
||||
}
|
||||
|
||||
bool AccountManager::hasValidAccessToken() {
|
||||
|
||||
if (_accountInfo.getAccessToken().token.isEmpty() || _accountInfo.getAccessToken().isExpired()) {
|
||||
|
|
|
@ -88,6 +88,7 @@ public:
|
|||
void requestProfile();
|
||||
|
||||
DataServerAccountInfo& getAccountInfo() { return _accountInfo; }
|
||||
void setAccountInfo(const DataServerAccountInfo &newAccountInfo);
|
||||
|
||||
static QJsonObject dataObjectFromResponse(QNetworkReply& requestReply);
|
||||
|
||||
|
|
Loading…
Reference in a new issue