Try to sign-in after being signed-out due to SslHandshakeFailedError

Signed-off-by: alex-z <blackslayer4@gmail.com>
This commit is contained in:
alex-z 2021-12-16 18:23:03 +02:00
parent d790bafcad
commit 62b0a9b9f1
4 changed files with 24 additions and 1 deletions

View file

@ -221,6 +221,19 @@ void AccountState::setDesktopNotificationsAllowed(bool isAllowed)
emit desktopNotificationsAllowedChanged();
}
AccountState::ConnectionStatus AccountState::lastConnectionStatus() const
{
return _lastConnectionValidatorStatus;
}
void AccountState::trySignIn()
{
if (isSignedOut() && account()) {
account()->resetRejectedCertificates();
signIn();
}
}
void AccountState::checkConnectivity()
{
if (isSignedOut() || _waitingForNewCredentials) {
@ -285,6 +298,8 @@ void AccountState::slotConnectionValidatorResult(ConnectionValidator::Status sta
return;
}
_lastConnectionValidatorStatus = status;
// Come online gradually from 503 or maintenance mode
if (status == ConnectionValidator::Connected
&& (_connectionStatus == ConnectionValidator::ServiceUnavailable

View file

@ -171,6 +171,10 @@ public:
*/
void setDesktopNotificationsAllowed(bool isAllowed);
ConnectionStatus lastConnectionStatus() const;
void trySignIn();
public slots:
/// Triggers a ping to the server to update state and
/// connection status and errors.
@ -205,6 +209,7 @@ private:
AccountPtr _account;
State _state;
ConnectionStatus _connectionStatus;
ConnectionStatus _lastConnectionValidatorStatus = ConnectionStatus::Undefined;
QStringList _connectionErrors;
bool _waitingForNewCredentials;
QDateTime _timeOfLastETagCheck;

View file

@ -465,6 +465,9 @@ void Application::slotCheckConnection()
if (state != AccountState::SignedOut && state != AccountState::ConfigurationError
&& state != AccountState::AskingCredentials && !pushNotificationsAvailable) {
accountState->checkConnectivity();
} else if (state == AccountState::SignedOut && accountState->lastConnectionStatus() == AccountState::ConnectionStatus::SslError) {
qCWarning(lcApplication) << "Account is signed out due to SSL Handshake error. Going to perform a sign-in attempt...";
accountState->trySignIn();
}
}

View file

@ -136,7 +136,7 @@ void ConnectionValidator::slotStatusFound(const QUrl &url, const QJsonObject &in
void ConnectionValidator::slotNoStatusFound(QNetworkReply *reply)
{
auto job = qobject_cast<CheckServerJob *>(sender());
qCWarning(lcConnectionValidator) << reply->error() << job->errorString() << reply->peek(1024);
qCWarning(lcConnectionValidator) << reply->error() << reply->errorString() << job->errorString() << reply->peek(1024);
if (reply->error() == QNetworkReply::SslHandshakeFailedError) {
reportResult(SslError);
return;