mirror of
https://github.com/nextcloud/server.git
synced 2026-05-25 18:52:53 -04:00
Merge pull request #59064 from nextcloud/backport/59061/stable27
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 php / php-lint (push) Waiting to run
Lint php / php-lint-summary (push) Blocked by required conditions
Node tests / versions (push) Waiting to run
Node tests / test (push) Blocked by required conditions
Node tests / jsunit (push) Blocked by required conditions
Node tests / handlebars (push) Blocked by required conditions
Node / node (push) Waiting to run
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
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 php / php-lint (push) Waiting to run
Lint php / php-lint-summary (push) Blocked by required conditions
Node tests / versions (push) Waiting to run
Node tests / test (push) Blocked by required conditions
Node tests / jsunit (push) Blocked by required conditions
Node tests / handlebars (push) Blocked by required conditions
Node / node (push) Waiting to run
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:
commit
cf1ce983d1
1 changed files with 8 additions and 3 deletions
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @copyright Copyright (c) 2017 Roger Szabo <roger.szabo@web.de>
|
||||
*
|
||||
|
|
@ -24,6 +25,7 @@
|
|||
namespace OCA\User_LDAP\Controller;
|
||||
|
||||
use OCP\AppFramework\Controller;
|
||||
use OCP\AppFramework\Http\Attribute\BruteForceProtection;
|
||||
use OCP\AppFramework\Http\RedirectResponse;
|
||||
use OCP\AppFramework\Http\TemplateResponse;
|
||||
use OCP\HintException;
|
||||
|
|
@ -127,23 +129,26 @@ class RenewPasswordController extends Controller {
|
|||
*
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
#[BruteForceProtection(action: 'login')]
|
||||
public function tryRenewPassword($user, $oldPassword, $newPassword) {
|
||||
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));
|
||||
|
|
|
|||
Loading…
Reference in a new issue