mirror of
https://github.com/nextcloud/server.git
synced 2026-05-19 08:25:56 -04:00
fix(lostpassword): Delete lost password token on password change
Signed-off-by: Carl Schwan <carl.schwan@nextcloud.com>
This commit is contained in:
parent
362a8578a2
commit
574ddff699
4 changed files with 41 additions and 4 deletions
|
|
@ -18,6 +18,7 @@ use OC\Authentication\Listeners\UserDeletedTokenCleanupListener;
|
|||
use OC\Authentication\Listeners\UserDeletedWebAuthnCleanupListener;
|
||||
use OC\Authentication\Notifications\Notifier as AuthenticationNotifier;
|
||||
use OC\Core\Listener\BeforeTemplateRenderedListener;
|
||||
use OC\Core\Listener\PasswordUpdatedListener;
|
||||
use OC\Core\Notification\CoreNotifier;
|
||||
use OC\TagManager;
|
||||
use OCP\AppFramework\App;
|
||||
|
|
@ -28,6 +29,7 @@ use OCP\DB\Events\AddMissingPrimaryKeyEvent;
|
|||
use OCP\EventDispatcher\IEventDispatcher;
|
||||
use OCP\Notification\IManager as INotificationManager;
|
||||
use OCP\User\Events\BeforeUserDeletedEvent;
|
||||
use OCP\User\Events\PasswordUpdatedEvent;
|
||||
use OCP\User\Events\UserDeletedEvent;
|
||||
use OCP\Util;
|
||||
|
||||
|
|
@ -305,6 +307,7 @@ class Application extends App {
|
|||
$eventDispatcher->addServiceListener(BeforeUserDeletedEvent::class, UserDeletedFilesCleanupListener::class);
|
||||
$eventDispatcher->addServiceListener(UserDeletedEvent::class, UserDeletedFilesCleanupListener::class);
|
||||
$eventDispatcher->addServiceListener(UserDeletedEvent::class, UserDeletedWebAuthnCleanupListener::class);
|
||||
$eventDispatcher->addServiceListener(PasswordUpdatedEvent::class, PasswordUpdatedListener::class);
|
||||
|
||||
// Tags
|
||||
$eventDispatcher->addServiceListener(UserDeletedEvent::class, TagManager::class);
|
||||
|
|
|
|||
32
core/Listener/PasswordUpdatedListener.php
Normal file
32
core/Listener/PasswordUpdatedListener.php
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace OC\Core\Listener;
|
||||
|
||||
use OCP\EventDispatcher\Event;
|
||||
use OCP\EventDispatcher\IEventListener;
|
||||
use OCP\Security\VerificationToken\IVerificationToken;
|
||||
use OCP\User\Events\PasswordUpdatedEvent;
|
||||
|
||||
/**
|
||||
* @template-implements IEventListener<PasswordUpdatedEvent>
|
||||
*/
|
||||
class PasswordUpdatedListener implements IEventListener {
|
||||
public function __construct(
|
||||
readonly private IVerificationToken $verificationToken,
|
||||
) {
|
||||
|
||||
}
|
||||
|
||||
public function handle(Event $event): void {
|
||||
if ($event instanceof PasswordUpdatedEvent) {
|
||||
$this->verificationToken->delete('', $event->getUser(), 'lostpassword');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1388,6 +1388,7 @@ return array(
|
|||
'OC\\Core\\Exception\\ResetPasswordException' => $baseDir . '/core/Exception/ResetPasswordException.php',
|
||||
'OC\\Core\\Listener\\BeforeMessageLoggedEventListener' => $baseDir . '/core/Listener/BeforeMessageLoggedEventListener.php',
|
||||
'OC\\Core\\Listener\\BeforeTemplateRenderedListener' => $baseDir . '/core/Listener/BeforeTemplateRenderedListener.php',
|
||||
'OC\\Core\\Listener\\PasswordUpdatedListener' => $baseDir . '/core/Listener/PasswordUpdatedListener.php',
|
||||
'OC\\Core\\Middleware\\TwoFactorMiddleware' => $baseDir . '/core/Middleware/TwoFactorMiddleware.php',
|
||||
'OC\\Core\\Migrations\\Version13000Date20170705121758' => $baseDir . '/core/Migrations/Version13000Date20170705121758.php',
|
||||
'OC\\Core\\Migrations\\Version13000Date20170718121200' => $baseDir . '/core/Migrations/Version13000Date20170718121200.php',
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
|
|||
);
|
||||
|
||||
public static $prefixLengthsPsr4 = array (
|
||||
'O' =>
|
||||
'O' =>
|
||||
array (
|
||||
'OC\\Core\\' => 8,
|
||||
'OC\\' => 3,
|
||||
|
|
@ -28,15 +28,15 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
|
|||
);
|
||||
|
||||
public static $prefixDirsPsr4 = array (
|
||||
'OC\\Core\\' =>
|
||||
'OC\\Core\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/../../..' . '/core',
|
||||
),
|
||||
'OC\\' =>
|
||||
'OC\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/../../..' . '/lib/private',
|
||||
),
|
||||
'OCP\\' =>
|
||||
'OCP\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/../../..' . '/lib/public',
|
||||
),
|
||||
|
|
@ -1437,6 +1437,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
|
|||
'OC\\Core\\Exception\\ResetPasswordException' => __DIR__ . '/../../..' . '/core/Exception/ResetPasswordException.php',
|
||||
'OC\\Core\\Listener\\BeforeMessageLoggedEventListener' => __DIR__ . '/../../..' . '/core/Listener/BeforeMessageLoggedEventListener.php',
|
||||
'OC\\Core\\Listener\\BeforeTemplateRenderedListener' => __DIR__ . '/../../..' . '/core/Listener/BeforeTemplateRenderedListener.php',
|
||||
'OC\\Core\\Listener\\PasswordUpdatedListener' => __DIR__ . '/../../..' . '/core/Listener/PasswordUpdatedListener.php',
|
||||
'OC\\Core\\Middleware\\TwoFactorMiddleware' => __DIR__ . '/../../..' . '/core/Middleware/TwoFactorMiddleware.php',
|
||||
'OC\\Core\\Migrations\\Version13000Date20170705121758' => __DIR__ . '/../../..' . '/core/Migrations/Version13000Date20170705121758.php',
|
||||
'OC\\Core\\Migrations\\Version13000Date20170718121200' => __DIR__ . '/../../..' . '/core/Migrations/Version13000Date20170718121200.php',
|
||||
|
|
|
|||
Loading…
Reference in a new issue