When your password changes out of bounds your Nextcloud tokens will become invalid. There is no real way around that. However we should make sure that if you successfully log in again your passwords are all updates * Added event listener to the PostLoggedInEvent so that we can act on it - Only if it is not a token login * Make sure that we actually reset the invalid state when we update a token. Else it keeps being marked invalid and thus not used. Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>pull/22524/head
parent
5826b75c40
commit
0452877a67
@ -0,0 +1,54 @@ |
||||
<?php |
||||
|
||||
declare(strict_types=1); |
||||
/** |
||||
* @copyright Copyright (c) 2020, Roeland Jago Douma <roeland@famdouma.nl> |
||||
* |
||||
* @author Roeland Jago Douma <roeland@famdouma.nl> |
||||
* |
||||
* @license GNU AGPL version 3 or any later version |
||||
* |
||||
* This program is free software: you can redistribute it and/or modify |
||||
* it under the terms of the GNU Affero General Public License as |
||||
* published by the Free Software Foundation, either version 3 of the |
||||
* License, or (at your option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU Affero General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU Affero General Public License |
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
||||
* |
||||
*/ |
||||
|
||||
namespace OC\Authentication\Listeners; |
||||
|
||||
use OC\Authentication\Token\Manager; |
||||
use OCP\EventDispatcher\Event; |
||||
use OCP\EventDispatcher\IEventListener; |
||||
use OCP\User\Events\PostLoginEvent; |
||||
|
||||
class UserLoggedInListener implements IEventListener { |
||||
|
||||
/** @var Manager */ |
||||
private $manager; |
||||
|
||||
public function __construct(Manager $manager) { |
||||
$this->manager = $manager; |
||||
} |
||||
|
||||
public function handle(Event $event): void { |
||||
if (!($event instanceof PostLoginEvent)) { |
||||
return; |
||||
} |
||||
|
||||
// If this is already a token login there is nothing to do |
||||
if ($event->isTokenLogin()) { |
||||
return; |
||||
} |
||||
|
||||
$this->manager->updatePasswords($event->getUser()->getUID(), $event->getPassword()); |
||||
} |
||||
} |
||||
Loading…
Reference in new issue