mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-23 13:35:58 +03:00
Merge pull request #3632 from nextcloud/bugfix/always-use-userid-after-login
Ensure that the users id is used for accessing webdav
This commit is contained in:
commit
b4d1d98868
3 changed files with 28 additions and 15 deletions
|
@ -16,12 +16,18 @@
|
|||
|
||||
#include "common/utility.h"
|
||||
#include "account.h"
|
||||
#include "creds/webflowcredentials.h"
|
||||
#include "networkjobs.h"
|
||||
#include "wizard/owncloudwizardcommon.h"
|
||||
#include "theme.h"
|
||||
#include "linklabel.h"
|
||||
|
||||
#include "QProgressIndicator.h"
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QStringLiteral>
|
||||
#include <QJsonObject>
|
||||
|
||||
namespace OCC {
|
||||
|
||||
Q_LOGGING_CATEGORY(lcFlow2AuthWidget, "nextcloud.gui.wizard.flow2authwidget", QtInfoMsg)
|
||||
|
@ -102,7 +108,25 @@ void Flow2AuthWidget::slotAuthResult(Flow2Auth::Result r, const QString &errorSt
|
|||
}
|
||||
}
|
||||
|
||||
_account->setCredentials(new WebFlowCredentials(user, appPassword));
|
||||
const auto fetchUserNameJob = new JsonApiJob(_account->sharedFromThis(), QStringLiteral("/ocs/v1.php/cloud/user"));
|
||||
connect(fetchUserNameJob, &JsonApiJob::jsonReceived, this, [this, fetchUserNameJob, r, errorString, user, appPassword](const QJsonDocument &json, int statusCode) {
|
||||
fetchUserNameJob->deleteLater();
|
||||
if (statusCode != 100) {
|
||||
qCWarning(lcFlow2AuthWidget) << "Could not fetch username";
|
||||
_account->setDavDisplayName(user);
|
||||
emit authResult(r, errorString, user, appPassword);
|
||||
return;
|
||||
}
|
||||
|
||||
const auto objData = json.object().value("ocs").toObject().value("data").toObject();
|
||||
const auto userId = objData.value("id").toString(user);
|
||||
const auto displayName = objData.value("display-name").toString();
|
||||
_account->setDavDisplayName(displayName);
|
||||
|
||||
emit authResult(r, errorString, userId, appPassword);
|
||||
});
|
||||
fetchUserNameJob->start();
|
||||
}
|
||||
|
||||
void Flow2AuthWidget::setError(const QString &error) {
|
||||
|
|
|
@ -168,7 +168,7 @@ void OwncloudAdvancedSetupPage::initializePage()
|
|||
_ui.confCheckBoxExternal->setChecked(cfgFile.confirmExternalStorage());
|
||||
|
||||
fetchUserAvatar();
|
||||
fetchUserData();
|
||||
setUserInformation();
|
||||
|
||||
customizeStyle();
|
||||
|
||||
|
@ -201,20 +201,9 @@ void OwncloudAdvancedSetupPage::fetchUserAvatar()
|
|||
avatarJob->start();
|
||||
}
|
||||
|
||||
void OwncloudAdvancedSetupPage::fetchUserData()
|
||||
void OwncloudAdvancedSetupPage::setUserInformation()
|
||||
{
|
||||
const auto account = _ocWizard->account();
|
||||
|
||||
// Fetch user data
|
||||
const auto userJob = new JsonApiJob(account, QLatin1String("ocs/v1.php/cloud/user"), this);
|
||||
userJob->setTimeout(20 * 1000);
|
||||
connect(userJob, &JsonApiJob::jsonReceived, this, [this](const QJsonDocument &json) {
|
||||
const auto objData = json.object().value("ocs").toObject().value("data").toObject();
|
||||
const auto displayName = objData.value("display-name").toString();
|
||||
_ui.userNameLabel->setText(displayName);
|
||||
});
|
||||
userJob->start();
|
||||
|
||||
const auto serverUrl = account->url().toString();
|
||||
setServerAddressLabelUrl(serverUrl);
|
||||
const auto userName = account->davDisplayName();
|
||||
|
|
|
@ -82,7 +82,7 @@ private:
|
|||
void setResolutionGuiVisible(bool value);
|
||||
void setupResoultionWidget();
|
||||
void fetchUserAvatar();
|
||||
void fetchUserData();
|
||||
void setUserInformation();
|
||||
|
||||
// TODO: remove when UX decision is made
|
||||
void refreshVirtualFilesAvailibility(const QString &path);
|
||||
|
|
Loading…
Reference in a new issue