Propagate errors during /login & /versions
This commit is contained in:
parent
9de1ec1b7b
commit
f6c279f6f2
@ -222,20 +222,8 @@ LoginPage::onServerAddressEntered()
|
|||||||
void
|
void
|
||||||
LoginPage::versionError(QString error)
|
LoginPage::versionError(QString error)
|
||||||
{
|
{
|
||||||
// Matrix homeservers are often kept on a subdomain called 'matrix'
|
|
||||||
// so let's try that next, unless the address was set explicitly or the domain
|
|
||||||
// part of the username already points to this subdomain
|
|
||||||
QUrl currentServer = client_->getHomeServer();
|
QUrl currentServer = client_->getHomeServer();
|
||||||
QString mxidAddress = matrixid_input_->text().split(":").at(1);
|
QString mxidAddress = matrixid_input_->text().split(":").at(1);
|
||||||
if (currentServer.host() == inferredServerAddress_ &&
|
|
||||||
!currentServer.host().startsWith("matrix")) {
|
|
||||||
error_label_->setText("");
|
|
||||||
currentServer.setHost(QString("matrix.") + currentServer.host());
|
|
||||||
serverInput_->setText(currentServer.host());
|
|
||||||
client_->setServer(currentServer.host());
|
|
||||||
client_->versions();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
error_label_->setText(error);
|
error_label_->setText(error);
|
||||||
serverInput_->show();
|
serverInput_->show();
|
||||||
|
@ -123,6 +123,11 @@ MatrixClient::login(const QString &username, const QString &password) noexcept
|
|||||||
int status_code =
|
int status_code =
|
||||||
reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||||
|
|
||||||
|
if (reply->error()) {
|
||||||
|
emit loginError(reply->errorString());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (status_code == 403) {
|
if (status_code == 403) {
|
||||||
emit loginError(tr("Wrong username or password"));
|
emit loginError(tr("Wrong username or password"));
|
||||||
return;
|
return;
|
||||||
@ -428,6 +433,11 @@ MatrixClient::versions() noexcept
|
|||||||
int status_code =
|
int status_code =
|
||||||
reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||||
|
|
||||||
|
if (reply->error()) {
|
||||||
|
emit versionError(reply->errorString());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (status_code == 404) {
|
if (status_code == 404) {
|
||||||
emit versionError("Versions endpoint was not found on the server. Possibly "
|
emit versionError("Versions endpoint was not found on the server. Possibly "
|
||||||
"not a Matrix server");
|
"not a Matrix server");
|
||||||
|
Loading…
Reference in New Issue
Block a user