Skip to content

Commit

Permalink
Merge pull request #28841 from nextcloud/backport/28794/stable22
Browse files Browse the repository at this point in the history
[stable22] allow using of disabled password reset mechanism for special cases
  • Loading branch information
Pytal authored Sep 15, 2021
2 parents 8549325 + 151fafc commit 4732aea
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions core/Controller/LostController.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,22 +134,24 @@ public function __construct(
* @return TemplateResponse
*/
public function resetform($token, $userId) {
if ($this->config->getSystemValue('lost_password_link', '') !== '') {
return new TemplateResponse('core', 'error', [
'errors' => [['error' => $this->l10n->t('Password reset is disabled')]]
],
'guest'
);
}

try {
$this->checkPasswordResetToken($token, $userId);
} catch (\Exception $e) {
return new TemplateResponse(
'core', 'error', [
"errors" => [["error" => $e->getMessage()]]
],
'guest'
if ($this->config->getSystemValue('lost_password_link', '') !== 'disabled'
|| ($e instanceof InvalidTokenException
&& !in_array($e->getCode(), [InvalidTokenException::TOKEN_NOT_FOUND, InvalidTokenException::USER_UNKNOWN]))
) {
return new TemplateResponse(
'core', 'error', [
"errors" => [["error" => $e->getMessage()]]
],
TemplateResponse::RENDER_AS_GUEST
);
}
return new TemplateResponse('core', 'error', [
'errors' => [['error' => $this->l10n->t('Password reset is disabled')]]
],
TemplateResponse::RENDER_AS_GUEST
);
}
$this->initialStateService->provideInitialState('core', 'resetPasswordUser', $userId);
Expand Down Expand Up @@ -242,10 +244,6 @@ public function email($user) {
* @return array
*/
public function setPassword($token, $userId, $password, $proceed) {
if ($this->config->getSystemValue('lost_password_link', '') !== '') {
return $this->error($this->l10n->t('Password reset is disabled'));
}

if ($this->encryptionManager->isEnabled() && !$proceed) {
$encryptionModules = $this->encryptionManager->getEncryptionModules();
foreach ($encryptionModules as $module) {
Expand Down

0 comments on commit 4732aea

Please sign in to comment.