Compare and store the login name via the event
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
0c7f0a7d89
commit
85781d8d36
|
@ -51,11 +51,14 @@ class StorePasswordListener implements IEventListener {
|
|||
}
|
||||
|
||||
$stored = $this->credentialsManager->retrieve($event->getUser()->getUID(), LoginCredentials::CREDENTIALS_IDENTIFIER);
|
||||
$update = $stored['password'] !== $event->getPassword();
|
||||
if (!$update && $event instanceof UserLoggedInEvent) {
|
||||
$update = $stored['user'] !== $event->getLoginName();
|
||||
}
|
||||
|
||||
if ($stored && ($stored['user'] !== $event->getUser()->getUID()
|
||||
|| $stored['password'] !== $event->getPassword())) {
|
||||
if ($stored && $update) {
|
||||
$credentials = [
|
||||
'user' => $event->getUser()->getUID(),
|
||||
'user' => $event->getLoginName(),
|
||||
'password' => $event->getPassword()
|
||||
];
|
||||
|
||||
|
|
|
@ -569,7 +569,7 @@ class Server extends ServerContainer implements IServerContainer {
|
|||
|
||||
/** @var IEventDispatcher $dispatcher */
|
||||
$dispatcher = $this->query(IEventDispatcher::class);
|
||||
$dispatcher->dispatchTyped(new UserLoggedInEvent($user, $password, $isTokenLogin));
|
||||
$dispatcher->dispatchTyped(new UserLoggedInEvent($user, $loginName, $password, $isTokenLogin));
|
||||
});
|
||||
$userSession->listen('\OC\User', 'preRememberedLogin', function ($uid) {
|
||||
/** @var IEventDispatcher $dispatcher */
|
||||
|
|
|
@ -43,14 +43,18 @@ class UserLoggedInEvent extends Event {
|
|||
/** @var bool */
|
||||
private $isTokenLogin;
|
||||
|
||||
/** @var string */
|
||||
private $loginName;
|
||||
|
||||
/**
|
||||
* @since 18.0.0
|
||||
*/
|
||||
public function __construct(IUser $user, string $password, bool $isTokenLogin) {
|
||||
public function __construct(IUser $user, string $loginName, string $password, bool $isTokenLogin) {
|
||||
parent::__construct();
|
||||
$this->user = $user;
|
||||
$this->password = $password;
|
||||
$this->isTokenLogin = $isTokenLogin;
|
||||
$this->loginName = $loginName;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -60,6 +64,13 @@ class UserLoggedInEvent extends Event {
|
|||
return $this->user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 21.0.0
|
||||
*/
|
||||
public function getLoginName(): string {
|
||||
return $this->loginName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 18.0.0
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue