added better error handling
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
parent
24aa337a64
commit
b0386a4c2f
@ -124,11 +124,16 @@ MSAStep::MSAStep(AccountData* data, bool silent) : AuthStep(data), m_silent(sile
|
|||||||
if (oauth2.status() == QAbstractOAuth::Status::Granted || silent) {
|
if (oauth2.status() == QAbstractOAuth::Status::Granted || silent) {
|
||||||
state = AccountTaskState::STATE_FAILED_SOFT;
|
state = AccountTaskState::STATE_FAILED_SOFT;
|
||||||
}
|
}
|
||||||
emit finished(state, tr("Microsoft user authentication failed."));
|
auto message = tr("Microsoft user authentication failed.");
|
||||||
|
if (silent) {
|
||||||
|
message = tr("Failed to refresh token.");
|
||||||
|
}
|
||||||
|
qWarning() << message;
|
||||||
|
emit finished(state, message);
|
||||||
});
|
});
|
||||||
connect(&oauth2, &QOAuth2AuthorizationCodeFlow::error, this,
|
connect(&oauth2, &QOAuth2AuthorizationCodeFlow::error, this,
|
||||||
[this](const QString& error, const QString& errorDescription, const QUrl& uri) {
|
[this](const QString& error, const QString& errorDescription, const QUrl& uri) {
|
||||||
qDebug() << "Failed to login because" << error << errorDescription;
|
qWarning() << "Failed to login because" << error << errorDescription;
|
||||||
emit finished(AccountTaskState::STATE_FAILED_HARD, errorDescription);
|
emit finished(AccountTaskState::STATE_FAILED_HARD, errorDescription);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -152,6 +157,10 @@ void MSAStep::perform()
|
|||||||
tr("Microsoft user authentication failed - client identification has changed."));
|
tr("Microsoft user authentication failed - client identification has changed."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (m_data->msaToken.refresh_token.isEmpty()) {
|
||||||
|
emit finished(AccountTaskState::STATE_DISABLED, tr("Microsoft user authentication failed - refresh token is empty."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
oauth2.setRefreshToken(m_data->msaToken.refresh_token);
|
oauth2.setRefreshToken(m_data->msaToken.refresh_token);
|
||||||
oauth2.refreshAccessToken();
|
oauth2.refreshAccessToken();
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user