diff --git a/qfieldsync/core/cloud_api.py b/qfieldsync/core/cloud_api.py
index 35363e4e..03b04cfa 100644
--- a/qfieldsync/core/cloud_api.py
+++ b/qfieldsync/core/cloud_api.py
@@ -691,24 +691,42 @@ def get_last_login_error(self) -> str:
if self.has_token():
return ""
+ suggest_forgotten_password = True
error_str = ""
+
if self._login_error:
- http_code = self._login_error.httpCode
- if http_code and http_code >= 500:
- error_str = self.tr("Server error {}").format(http_code)
- elif http_code is None or (http_code >= 400 and http_code < 500):
- error_str = str(self._login_error)
+ reply = self._login_error.reply
+
+ if (
+ reply.error() == QNetworkReply.HostNotFoundError
+ # network unreachable goes here
+ or reply.error() == QNetworkReply.UnknownNetworkError
+ ):
+ error_str = self.tr(
+ "Failed to connect to {}. Check your internet connection.".format(
+ self.url
+ )
+ )
+ suggest_forgotten_password = False
+ else:
+ http_code = self._login_error.httpCode
+
+ if http_code and http_code >= 500:
+ error_str = self.tr("Server error {}").format(http_code)
+ elif http_code is None or (http_code >= 400 and http_code < 500):
+ error_str = str(self._login_error)
error_str = strip_html(error_str).strip()
if not error_str:
error_str = self.tr("Sign in failed.")
- html = '{}?'.format(
- self.tr("Forgot password")
- )
+ if suggest_forgotten_password:
+ error_str += ' {}?'.format(
+ self.url, self.tr("Forgot password")
+ )
- return self.tr("{}. {}").format(error_str, html)
+ return error_str
def _clear_cloud_cookies(self, url: QUrl) -> None:
"""When the CSRF_TOKEN cookie is present and the plugin is reloaded, the token has expired"""