From d4e22ed0d2944bd361e73d69f2672a20237b3372 Mon Sep 17 00:00:00 2001 From: lasconic Date: Wed, 11 Mar 2015 17:02:45 +0100 Subject: [PATCH] review error cases for MuseScore.com login --- mscore/loginmanager.cpp | 5 +++++ thirdparty/kQOAuth/kqoauthmanager.cpp | 16 +++++++--------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/mscore/loginmanager.cpp b/mscore/loginmanager.cpp index 2977d628cd20..9a568605ecfc 100644 --- a/mscore/loginmanager.cpp +++ b/mscore/loginmanager.cpp @@ -103,6 +103,10 @@ void LoginManager::onAuthorizedRequestDone() QMessageBox::critical(0, tr("Network error"), tr("Please check your Internet connection")); else if (_oauthManager->lastError() == KQOAuthManager::ContentOperationNotPermittedError) QMessageBox::critical(0, tr("Please upgrade"), tr("Your MuseScore version is too old to use this feature.
Please upgrade first.").arg("http://musescore.org")); + else if (_oauthManager->lastError() == KQOAuthManager::RequestUnauthorized){ + logout(); + mscore->showLoginDialog(); + } } /*------- TRY LOGIN ROUTINES ----------------------------*/ @@ -142,6 +146,7 @@ void LoginManager::onTryLoginError(const QString& error) disconnect(this, SIGNAL(getUserSuccess()), this, SLOT(onTryLoginSuccess())); disconnect(this, SIGNAL(getUserError(QString)), this, SLOT(onTryLoginError(QString))); connect(this, SIGNAL(loginSuccess()), this, SLOT(tryLogin())); + logout(); mscore->showLoginDialog(); } /*------- END - TRY LOGIN ROUTINES ----------------------------*/ diff --git a/thirdparty/kQOAuth/kqoauthmanager.cpp b/thirdparty/kQOAuth/kqoauthmanager.cpp index 787458edad17..4bd6e83842fa 100644 --- a/thirdparty/kQOAuth/kqoauthmanager.cpp +++ b/thirdparty/kQOAuth/kqoauthmanager.cpp @@ -586,13 +586,6 @@ void KQOAuthManager::onRequestReplyReceived() { foreach (QNetworkCookie cookie , c) qDebug() << cookie.name() << cookie.value();*/ - // Just don't do anything if we didn't get anything useful. - if(networkReply.isEmpty()) { - reply->deleteLater(); - return; - } - QMultiMap responseTokens; - // We need to emit the signal even if we got an error. if (d->error != KQOAuthManager::NoError) { reply->deleteLater(); @@ -601,6 +594,13 @@ void KQOAuthManager::onRequestReplyReceived() { return; } + // Just don't do anything if we didn't get anything useful. + if(networkReply.isEmpty()) { + reply->deleteLater(); + return; + } + QMultiMap responseTokens; + responseTokens = d->createTokensFromResponse(networkReply); d->opaqueRequest->clearRequest(); d->opaqueRequest->setHttpMethod(KQOAuthRequest::POST); // XXX FIXME: Convenient API does not support GET @@ -671,8 +671,6 @@ void KQOAuthManager::onAuthorizedRequestReplyReceived() { d->currentRequestType = d->r->requestType(); } - - // Just don't do anything if we didn't get anything useful. if(networkReply.isEmpty()) { reply->deleteLater();