diff --git a/qml/pages/setup/LoginDialog.qml b/qml/pages/setup/LoginDialog.qml index 7fd6487..07b7739 100644 --- a/qml/pages/setup/LoginDialog.qml +++ b/qml/pages/setup/LoginDialog.qml @@ -97,8 +97,8 @@ Dialog { model: userModel delegate: UserGridDelegate { name: model.name - image: model.primaryImageTag ? "%1/Users/%2/Images/Primary?tag=%3".arg(ApiClient.baseUrl).arg(model.id).arg(model.primaryImageTag) : null - highlighted: model.name == username.text + image: model.primaryImageTag ? "%1/Users/%2/Images/Primary?tag=%3".arg(ApiClient.baseUrl).arg(model.id).arg(model.primaryImageTag) : "" + highlighted: model.name === username.text onClicked: { username.text = model.name password.focus = true diff --git a/src/jellyfinapiclient.cpp b/src/jellyfinapiclient.cpp index db0a6a3..83d1d4d 100644 --- a/src/jellyfinapiclient.cpp +++ b/src/jellyfinapiclient.cpp @@ -126,31 +126,25 @@ void ApiClient::setupConnection() { // First detect redirects: // Note that this is done without calling JellyfinApiClient::get since that automatically includes the base_url, // which is something we want to avoid here. - QNetworkReply *rep = m_naManager.get(QNetworkRequest(m_baseUrl)); + QNetworkRequest req = QNetworkRequest(m_baseUrl); + req.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true); + QNetworkReply *rep = m_naManager.get(req); connect(rep, &QNetworkReply::finished, this, [rep, this](){ int status = statusCode(rep); qDebug() << status; - // Check if redirect - if (status >= 300 && status < 400) { - QString location = QString::fromUtf8(rep->rawHeader("location")); - qInfo() << "Redirect from " << this->m_baseUrl << " to " << location; - QUrl base = QUrl(m_baseUrl); - QString newUrl = base.resolved(QUrl(location)).toString(); - // If the url wants to redirect us to their web interface, we have to chop the last part of. - if (newUrl.endsWith("/web/index.html")) { - newUrl.chop(QString("/web/index.html").size()); - this->setBaseUrl(newUrl); - getBrandingConfiguration(); - } else { - this->setBaseUrl(newUrl); - setupConnection(); - } - } else { - getBrandingConfiguration(); + QString newUrl = rep->url().toString(); + // If the server wants to redirect us to their web interface, we have to chop the last part of the url off. + if (newUrl.endsWith("/web/index.html")) { + newUrl.chop(QString("/web/index.html").size()); + this->setBaseUrl(newUrl); } + this->getBrandingConfiguration(); rep->deleteLater(); }); + connect(rep, &QNetworkReply::redirected, this, [req] (const QUrl &url) { + qDebug() << "Redirect from " << req.url() << " to " << url; + }); setDefaultErrorHandler(rep); }