Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/4'
Browse files Browse the repository at this point in the history
  • Loading branch information
TheOneRing committed May 26, 2023
2 parents 7abf377 + 3457e89 commit eae9e64
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 64 deletions.
18 changes: 0 additions & 18 deletions .drone.star
Original file line number Diff line number Diff line change
Expand Up @@ -314,25 +314,7 @@ def changelog(ctx):
"kind": "pipeline",
"type": "docker",
"name": "changelog",
"clone": {
"disable": True,
},
"steps": [
{
"name": "clone",
"image": PLUGINS_GIT_ACTION,
"settings": {
"actions": [
"clone",
],
"remote": "https://github.com/%s" % (repo_slug),
"branch": ctx.build.source if ctx.build.event == "pull_request" else "master",
"path": dir["base"],
"netrc_machine": "github.com",
"netrc_username": from_secret("github_username"),
"netrc_password": from_secret("github_token"),
},
},
{
"name": "generate",
"image": TOOLHIPPIE_CALENS,
Expand Down
6 changes: 6 additions & 0 deletions changelog/unreleased/10856
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: Use correct user name with basic auth and LDAP

Whith basic auth the name from the login credentials might not align with the name on the server.
We corrected the assumption and no longer change the user name.

https://github.com/owncloud/client/issues/10856
6 changes: 6 additions & 0 deletions changelog/unreleased/enterprise-5743
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: Follow same site redirects in the Wizard

We fixed a bug where the client did not follow same site redirects during the setup.
If the used url https://test.com/owncloud redirected to https://test.com the new url was not correctly used for the newly created account.

https://github.com/owncloud/enterprise/issues/5743
2 changes: 1 addition & 1 deletion src/gui/creds/httpcredentialsgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ void HttpCredentialsGui::showDialog()
dialog->setTopLabelText(tr("Please enter your password to log in to your account."));

auto *contentWidget = qobject_cast<BasicLoginWidget *>(dialog->contentWidget());
contentWidget->forceUsername(_account->davUser());
contentWidget->forceUsername(user());

// in this case, we want to use the login button
dialog->addLogInButton();
Expand Down
11 changes: 8 additions & 3 deletions src/gui/newwizard/setupwizardcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,17 @@ void SetupWizardController::changeStateTo(SetupWizardState nextState)
connect(fetchUserInfoJob, &CoreJob::finished, this, [this, fetchUserInfoJob] {
if (fetchUserInfoJob->success()) {
auto result = fetchUserInfoJob->result().value<FetchUserInfoResult>();

_context->accountBuilder().setDisplayName(result.displayName());
_context->accountBuilder().authenticationStrategy()->setDavUser(result.userName());
// with basic auth the login name and the webdav username might not match
if (_context->accountBuilder().authType() == DetermineAuthTypeJob::AuthType::OAuth) {
_context->accountBuilder().authenticationStrategy()->setDavUser(result.userName());
}
changeStateTo(SetupWizardState::AccountConfiguredState);
} else if (fetchUserInfoJob->reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() == 401) {
_context->window()->showErrorMessage(tr("Invalid credentials"));
changeStateTo(_currentState->state());
} else {
_context->window()->showErrorMessage(QStringLiteral("Failed to retrieve user information from server"));
_context->window()->showErrorMessage(tr("Failed to retrieve user information from server"));
changeStateTo(_currentState->state());
}
});
Expand Down
35 changes: 1 addition & 34 deletions src/gui/newwizard/states/basiccredentialssetupwizardstate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,40 +42,7 @@ void BasicCredentialsSetupWizardState::evaluatePage()
if (!_context->accountBuilder().hasValidCredentials()) {
Q_EMIT evaluationFailed(tr("Invalid credentials"));
}

auto strategy = dynamic_cast<HttpBasicAuthenticationStrategy *>(_context->accountBuilder().authenticationStrategy());
Q_ASSERT(strategy != nullptr);

auto checkBasicAuthJob = Jobs::CheckBasicAuthJobFactory(_context->accessManager(), strategy->username(), strategy->password()).startJob(_context->accountBuilder().serverUrl(), this);

connect(checkBasicAuthJob, &CoreJob::finished, this, [checkBasicAuthJob, this, strategy]() {
if (checkBasicAuthJob->success()) {
if (checkBasicAuthJob->result().toBool()) {
auto fetchUserInfoJob = FetchUserInfoJobFactory::fromBasicAuthCredentials(_context->accessManager(), strategy->username(), strategy->password()).startJob(_context->accountBuilder().serverUrl(), this);

connect(fetchUserInfoJob, &CoreJob::finished, this, [this, strategy, fetchUserInfoJob] {
if (fetchUserInfoJob->success()) {
auto result = fetchUserInfoJob->result().value<FetchUserInfoResult>();

Q_ASSERT(result.userName() == strategy->username());

_context->accountBuilder().setDisplayName(result.displayName());

Q_EMIT evaluationSuccessful();
} else {
Q_EMIT evaluationFailed(tr("Failed to fetch user display name"));
}
});

} else {
Q_EMIT evaluationFailed(tr("Login failed: username and/or password incorrect"));
}


} else {
Q_EMIT evaluationFailed(tr("Login failed: %1").arg(checkBasicAuthJob->errorMessage()));
}
});
Q_EMIT evaluationSuccessful();
}

SetupWizardState BasicCredentialsSetupWizardState::state() const
Expand Down
10 changes: 5 additions & 5 deletions src/gui/newwizard/states/serverurlsetupwizardstate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,15 @@ void ServerUrlSetupWizardState::evaluatePage()
// first, we must resolve the actual server URL
auto resolveJob = Jobs::ResolveUrlJobFactory(_context->accessManager()).startJob(serverUrl, this);

connect(resolveJob, &CoreJob::finished, resolveJob, [this, resolveJob, serverUrl]() {
connect(resolveJob, &CoreJob::finished, resolveJob, [this, resolveJob]() {
resolveJob->deleteLater();

if (!resolveJob->success()) {
Q_EMIT evaluationFailed(resolveJob->errorMessage());
return;
}

const auto resolvedUrl = qvariant_cast<QUrl>(resolveJob->result());
const auto resolvedUrl = resolveJob->result().toUrl();

// classic WebFinger workflow: auth type determination is delegated to whatever server the WebFinger service points us to in a dedicated
// step we can skip it here therefore
Expand All @@ -135,17 +135,17 @@ void ServerUrlSetupWizardState::evaluatePage()
}

// next, we need to find out which kind of authentication page we have to present to the user
auto authTypeJob = DetermineAuthTypeJobFactory(_context->accessManager()).startJob(serverUrl, this);
auto authTypeJob = DetermineAuthTypeJobFactory(_context->accessManager()).startJob(resolvedUrl, this);

connect(authTypeJob, &CoreJob::finished, authTypeJob, [this, authTypeJob, serverUrl]() {
connect(authTypeJob, &CoreJob::finished, authTypeJob, [this, authTypeJob, resolvedUrl]() {
authTypeJob->deleteLater();

if (authTypeJob->result().isNull()) {
Q_EMIT evaluationFailed(authTypeJob->errorMessage());
return;
}

_context->accountBuilder().setServerUrl(serverUrl, qvariant_cast<DetermineAuthTypeJob::AuthType>(authTypeJob->result()));
_context->accountBuilder().setServerUrl(resolvedUrl, qvariant_cast<DetermineAuthTypeJob::AuthType>(authTypeJob->result()));
Q_EMIT evaluationSuccessful();
});
});
Expand Down
3 changes: 0 additions & 3 deletions test/testoauth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,9 +326,6 @@ private slots:
OC_ASSERT(browserReply);
// simulate the fact that the browser is closing the connection
browserReply->abort();
// don't process network events, as it messes up the execution order and
// causes an Qt internal crash
QCoreApplication::processEvents(QEventLoop::ExcludeSocketNotifiers);

OC_ASSERT(state == BrowserOpened);
state = TokenAsked;
Expand Down

0 comments on commit eae9e64

Please sign in to comment.