Merge pull request #59069 from nextcloud/backport/59064/stable26
Some checks are pending
Cypress / init (push) Waiting to run
Cypress / runner 1 (push) Blocked by required conditions
Cypress / runner 2 (push) Blocked by required conditions
Cypress / runner component (push) Blocked by required conditions
Cypress / cypress-summary (push) Blocked by required conditions
Lint eslint / eslint (push) Waiting to run
Lint php / php-lint (push) Waiting to run
Lint php / php-lint-summary (push) Blocked by required conditions
Node / versions (push) Waiting to run
Node / test (push) Blocked by required conditions
Node / jsunit (push) Blocked by required conditions
Node / handlebars (push) Blocked by required conditions
Node / node (push) Waiting to run
S3 primary storage integration tests / php8.0-objectstore-minio (push) Waiting to run
S3 primary storage integration tests / php8.0-objectstore_multibucket-minio (push) Waiting to run
S3 primary storage integration tests / s3-primary-integration-summary (push) Blocked by required conditions
S3 primary storage / php8.0-objectstore-minio (push) Waiting to run
S3 primary storage / php8.0-objectstore_multibucket-minio (push) Waiting to run
S3 primary storage / s3-primary-summary (push) Blocked by required conditions
Psalm static code analysis / static-code-analysis (push) Waiting to run
Psalm static code analysis / static-code-analysis-security (push) Waiting to run
Psalm static code analysis / static-code-analysis-ocp (push) Waiting to run

This commit is contained in:
Benjamin Gaussorgues 2026-03-19 16:09:34 +01:00 committed by GitHub
commit 816273d035
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,4 +1,5 @@
<?php
/**
* @copyright Copyright (c) 2017 Roger Szabo <roger.szabo@web.de>
*
@ -120,6 +121,7 @@ class RenewPasswordController extends Controller {
/**
* @PublicPage
* @UseSession
* @BruteForceProtection(action=login)
*
* @param string $user
* @param string $oldPassword
@ -131,19 +133,21 @@ class RenewPasswordController extends Controller {
if ($this->config->getUserValue($user, 'user_ldap', 'needsPasswordReset') !== 'true') {
return new RedirectResponse($this->urlGenerator->linkToRouteAbsolute('core.login.showLoginForm'));
}
$args = !is_null($user) ? ['user' => $user] : [];
$args = ['user' => $user];
$loginResult = $this->userManager->checkPassword($user, $oldPassword);
if ($loginResult === false) {
$this->session->set('renewPasswordMessages', [
['invalidpassword'], []
]);
return new RedirectResponse($this->urlGenerator->linkToRoute('user_ldap.renewPassword.showRenewPasswordForm', $args));
$response = new RedirectResponse($this->urlGenerator->linkToRoute('user_ldap.renewPassword.showRenewPasswordForm', $args));
$response->throttle(['user' => $user]);
return $response;
}
try {
if (!is_null($newPassword) && \OC_User::setPassword($user, $newPassword)) {
$this->session->set('loginMessages', [
[], [$this->l10n->t("Please login with the new password")]
[], [$this->l10n->t('Please login with the new password')]
]);
$this->config->setUserValue($user, 'user_ldap', 'needsPasswordReset', 'false');
return new RedirectResponse($this->urlGenerator->linkToRoute('core.login.showLoginForm', $args));