Merge pull request #18348 from nextcloud/enhancement/typed-user-events-II
Add typed events for all user hooks and legacy events
This commit is contained in:
commit
917f1807fd
|
@ -452,9 +452,21 @@ return array(
|
|||
'OCP\\User\\Backend\\IProvideAvatarBackend' => $baseDir . '/lib/public/User/Backend/IProvideAvatarBackend.php',
|
||||
'OCP\\User\\Backend\\ISetDisplayNameBackend' => $baseDir . '/lib/public/User/Backend/ISetDisplayNameBackend.php',
|
||||
'OCP\\User\\Backend\\ISetPasswordBackend' => $baseDir . '/lib/public/User/Backend/ISetPasswordBackend.php',
|
||||
'OCP\\User\\Events\\BeforePasswordUpdatedEvent' => $baseDir . '/lib/public/User/Events/BeforePasswordUpdatedEvent.php',
|
||||
'OCP\\User\\Events\\BeforeUserCreatedEvent' => $baseDir . '/lib/public/User/Events/BeforeUserCreatedEvent.php',
|
||||
'OCP\\User\\Events\\BeforeUserDeletedEvent' => $baseDir . '/lib/public/User/Events/BeforeUserDeletedEvent.php',
|
||||
'OCP\\User\\Events\\BeforeUserLoggedInEvent' => $baseDir . '/lib/public/User/Events/BeforeUserLoggedInEvent.php',
|
||||
'OCP\\User\\Events\\BeforeUserLoggedInWithCookieEvent' => $baseDir . '/lib/public/User/Events/BeforeUserLoggedInWithCookieEvent.php',
|
||||
'OCP\\User\\Events\\BeforeUserLoggedOutEvent' => $baseDir . '/lib/public/User/Events/BeforeUserLoggedOutEvent.php',
|
||||
'OCP\\User\\Events\\CreateUserEvent' => $baseDir . '/lib/public/User/Events/CreateUserEvent.php',
|
||||
'OCP\\User\\Events\\PasswordUpdatedEvent' => $baseDir . '/lib/public/User/Events/PasswordUpdatedEvent.php',
|
||||
'OCP\\User\\Events\\PostLoginEvent' => $baseDir . '/lib/public/User/Events/PostLoginEvent.php',
|
||||
'OCP\\User\\Events\\UserChangedEvent' => $baseDir . '/lib/public/User/Events/UserChangedEvent.php',
|
||||
'OCP\\User\\Events\\UserCreatedEvent' => $baseDir . '/lib/public/User/Events/UserCreatedEvent.php',
|
||||
'OCP\\User\\Events\\UserDeletedEvent' => $baseDir . '/lib/public/User/Events/UserDeletedEvent.php',
|
||||
'OCP\\User\\Events\\UserLoggedInEvent' => $baseDir . '/lib/public/User/Events/UserLoggedInEvent.php',
|
||||
'OCP\\User\\Events\\UserLoggedInWithCookieEvent' => $baseDir . '/lib/public/User/Events/UserLoggedInWithCookieEvent.php',
|
||||
'OCP\\User\\Events\\UserLoggedOutEvent' => $baseDir . '/lib/public/User/Events/UserLoggedOutEvent.php',
|
||||
'OCP\\Util' => $baseDir . '/lib/public/Util.php',
|
||||
'OCP\\WorkflowEngine\\EntityContext\\IDisplayName' => $baseDir . '/lib/public/WorkflowEngine/EntityContext/IDisplayName.php',
|
||||
'OCP\\WorkflowEngine\\EntityContext\\IDisplayText' => $baseDir . '/lib/public/WorkflowEngine/EntityContext/IDisplayText.php',
|
||||
|
|
|
@ -481,9 +481,21 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
|
|||
'OCP\\User\\Backend\\IProvideAvatarBackend' => __DIR__ . '/../../..' . '/lib/public/User/Backend/IProvideAvatarBackend.php',
|
||||
'OCP\\User\\Backend\\ISetDisplayNameBackend' => __DIR__ . '/../../..' . '/lib/public/User/Backend/ISetDisplayNameBackend.php',
|
||||
'OCP\\User\\Backend\\ISetPasswordBackend' => __DIR__ . '/../../..' . '/lib/public/User/Backend/ISetPasswordBackend.php',
|
||||
'OCP\\User\\Events\\BeforePasswordUpdatedEvent' => __DIR__ . '/../../..' . '/lib/public/User/Events/BeforePasswordUpdatedEvent.php',
|
||||
'OCP\\User\\Events\\BeforeUserCreatedEvent' => __DIR__ . '/../../..' . '/lib/public/User/Events/BeforeUserCreatedEvent.php',
|
||||
'OCP\\User\\Events\\BeforeUserDeletedEvent' => __DIR__ . '/../../..' . '/lib/public/User/Events/BeforeUserDeletedEvent.php',
|
||||
'OCP\\User\\Events\\BeforeUserLoggedInEvent' => __DIR__ . '/../../..' . '/lib/public/User/Events/BeforeUserLoggedInEvent.php',
|
||||
'OCP\\User\\Events\\BeforeUserLoggedInWithCookieEvent' => __DIR__ . '/../../..' . '/lib/public/User/Events/BeforeUserLoggedInWithCookieEvent.php',
|
||||
'OCP\\User\\Events\\BeforeUserLoggedOutEvent' => __DIR__ . '/../../..' . '/lib/public/User/Events/BeforeUserLoggedOutEvent.php',
|
||||
'OCP\\User\\Events\\CreateUserEvent' => __DIR__ . '/../../..' . '/lib/public/User/Events/CreateUserEvent.php',
|
||||
'OCP\\User\\Events\\PasswordUpdatedEvent' => __DIR__ . '/../../..' . '/lib/public/User/Events/PasswordUpdatedEvent.php',
|
||||
'OCP\\User\\Events\\PostLoginEvent' => __DIR__ . '/../../..' . '/lib/public/User/Events/PostLoginEvent.php',
|
||||
'OCP\\User\\Events\\UserChangedEvent' => __DIR__ . '/../../..' . '/lib/public/User/Events/UserChangedEvent.php',
|
||||
'OCP\\User\\Events\\UserCreatedEvent' => __DIR__ . '/../../..' . '/lib/public/User/Events/UserCreatedEvent.php',
|
||||
'OCP\\User\\Events\\UserDeletedEvent' => __DIR__ . '/../../..' . '/lib/public/User/Events/UserDeletedEvent.php',
|
||||
'OCP\\User\\Events\\UserLoggedInEvent' => __DIR__ . '/../../..' . '/lib/public/User/Events/UserLoggedInEvent.php',
|
||||
'OCP\\User\\Events\\UserLoggedInWithCookieEvent' => __DIR__ . '/../../..' . '/lib/public/User/Events/UserLoggedInWithCookieEvent.php',
|
||||
'OCP\\User\\Events\\UserLoggedOutEvent' => __DIR__ . '/../../..' . '/lib/public/User/Events/UserLoggedOutEvent.php',
|
||||
'OCP\\Util' => __DIR__ . '/../../..' . '/lib/public/Util.php',
|
||||
'OCP\\WorkflowEngine\\EntityContext\\IDisplayName' => __DIR__ . '/../../..' . '/lib/public/WorkflowEngine/EntityContext/IDisplayName.php',
|
||||
'OCP\\WorkflowEngine\\EntityContext\\IDisplayText' => __DIR__ . '/../../..' . '/lib/public/WorkflowEngine/EntityContext/IDisplayText.php',
|
||||
|
|
|
@ -113,7 +113,6 @@ use OC\Security\Bruteforce\Throttler;
|
|||
use OC\Security\CertificateManager;
|
||||
use OC\Security\CredentialsManager;
|
||||
use OC\Security\Crypto;
|
||||
use OC\Security\CSP\ContentSecurityPolicyManager;
|
||||
use OC\Security\CSP\ContentSecurityPolicyNonceManager;
|
||||
use OC\Security\CSRF\CsrfTokenGenerator;
|
||||
use OC\Security\CSRF\CsrfTokenManager;
|
||||
|
@ -163,6 +162,19 @@ use OCP\Remote\IInstanceFactory;
|
|||
use OCP\RichObjectStrings\IValidator;
|
||||
use OCP\Security\IContentSecurityPolicyManager;
|
||||
use OCP\Share\IShareHelper;
|
||||
use OCP\User\Events\BeforePasswordUpdatedEvent;
|
||||
use OCP\User\Events\BeforeUserCreatedEvent;
|
||||
use OCP\User\Events\BeforeUserDeletedEvent;
|
||||
use OCP\User\Events\BeforeUserLoggedInEvent;
|
||||
use OCP\User\Events\BeforeUserLoggedInWithCookieEvent;
|
||||
use OCP\User\Events\BeforeUserLoggedOutEvent;
|
||||
use OCP\User\Events\PasswordUpdatedEvent;
|
||||
use OCP\User\Events\UserChangedEvent;
|
||||
use OCP\User\Events\UserCreatedEvent;
|
||||
use OCP\User\Events\UserDeletedEvent;
|
||||
use OCP\User\Events\UserLoggedInEvent;
|
||||
use OCP\User\Events\UserLoggedInWithCookieEvent;
|
||||
use OCP\User\Events\UserLoggedOutEvent;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\EventDispatcher\GenericEvent;
|
||||
|
||||
|
@ -380,7 +392,7 @@ class Server extends ServerContainer implements IServerContainer {
|
|||
$defaultTokenProvider = null;
|
||||
}
|
||||
|
||||
$dispatcher = $c->getEventDispatcher();
|
||||
$legacyDispatcher = $c->getEventDispatcher();
|
||||
|
||||
$userSession = new \OC\User\Session(
|
||||
$manager,
|
||||
|
@ -395,45 +407,99 @@ class Server extends ServerContainer implements IServerContainer {
|
|||
);
|
||||
$userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
|
||||
\OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password));
|
||||
|
||||
/** @var IEventDispatcher $dispatcher */
|
||||
$dispatcher = $this->query(IEventDispatcher::class);
|
||||
$dispatcher->dispatchTyped(new BeforeUserCreatedEvent($uid, $password));
|
||||
});
|
||||
$userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) {
|
||||
/** @var $user \OC\User\User */
|
||||
\OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password));
|
||||
|
||||
/** @var IEventDispatcher $dispatcher */
|
||||
$dispatcher = $this->query(IEventDispatcher::class);
|
||||
$dispatcher->dispatchTyped(new UserCreatedEvent($user, $password));
|
||||
});
|
||||
$userSession->listen('\OC\User', 'preDelete', function ($user) use ($dispatcher) {
|
||||
$userSession->listen('\OC\User', 'preDelete', function ($user) use ($legacyDispatcher) {
|
||||
/** @var $user \OC\User\User */
|
||||
\OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID()));
|
||||
$dispatcher->dispatch('OCP\IUser::preDelete', new GenericEvent($user));
|
||||
$legacyDispatcher->dispatch('OCP\IUser::preDelete', new GenericEvent($user));
|
||||
|
||||
/** @var IEventDispatcher $dispatcher */
|
||||
$dispatcher = $this->query(IEventDispatcher::class);
|
||||
$dispatcher->dispatchTyped(new BeforeUserDeletedEvent($user));
|
||||
});
|
||||
$userSession->listen('\OC\User', 'postDelete', function ($user) {
|
||||
/** @var $user \OC\User\User */
|
||||
\OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID()));
|
||||
|
||||
/** @var IEventDispatcher $dispatcher */
|
||||
$dispatcher = $this->query(IEventDispatcher::class);
|
||||
$dispatcher->dispatchTyped(new UserDeletedEvent($user));
|
||||
});
|
||||
$userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
|
||||
/** @var $user \OC\User\User */
|
||||
\OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
|
||||
|
||||
/** @var IEventDispatcher $dispatcher */
|
||||
$dispatcher = $this->query(IEventDispatcher::class);
|
||||
$dispatcher->dispatchTyped(new BeforePasswordUpdatedEvent($user, $password, $recoveryPassword));
|
||||
});
|
||||
$userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
|
||||
/** @var $user \OC\User\User */
|
||||
\OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
|
||||
|
||||
/** @var IEventDispatcher $dispatcher */
|
||||
$dispatcher = $this->query(IEventDispatcher::class);
|
||||
$dispatcher->dispatchTyped(new PasswordUpdatedEvent($user, $password, $recoveryPassword));
|
||||
});
|
||||
$userSession->listen('\OC\User', 'preLogin', function ($uid, $password) {
|
||||
\OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password));
|
||||
|
||||
/** @var IEventDispatcher $dispatcher */
|
||||
$dispatcher = $this->query(IEventDispatcher::class);
|
||||
$dispatcher->dispatchTyped(new BeforeUserLoggedInEvent($uid, $password));
|
||||
});
|
||||
$userSession->listen('\OC\User', 'postLogin', function ($user, $password, $isTokenLogin) {
|
||||
/** @var $user \OC\User\User */
|
||||
\OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'isTokenLogin' => $isTokenLogin));
|
||||
|
||||
/** @var IEventDispatcher $dispatcher */
|
||||
$dispatcher = $this->query(IEventDispatcher::class);
|
||||
$dispatcher->dispatchTyped(new UserLoggedInEvent($user, $password, $isTokenLogin));
|
||||
});
|
||||
$userSession->listen('\OC\User', 'preRememberedLogin', function ($uid) {
|
||||
/** @var IEventDispatcher $dispatcher */
|
||||
$dispatcher = $this->query(IEventDispatcher::class);
|
||||
$dispatcher->dispatchTyped(new BeforeUserLoggedInWithCookieEvent($uid));
|
||||
});
|
||||
$userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) {
|
||||
/** @var $user \OC\User\User */
|
||||
\OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password));
|
||||
|
||||
/** @var IEventDispatcher $dispatcher */
|
||||
$dispatcher = $this->query(IEventDispatcher::class);
|
||||
$dispatcher->dispatchTyped(new UserLoggedInWithCookieEvent($user, $password));
|
||||
});
|
||||
$userSession->listen('\OC\User', 'logout', function () {
|
||||
$userSession->listen('\OC\User', 'logout', function ($user) {
|
||||
\OC_Hook::emit('OC_User', 'logout', array());
|
||||
|
||||
/** @var IEventDispatcher $dispatcher */
|
||||
$dispatcher = $this->query(IEventDispatcher::class);
|
||||
$dispatcher->dispatchTyped(new BeforeUserLoggedOutEvent($user));
|
||||
});
|
||||
$userSession->listen('\OC\User', 'postLogout', function ($user) {
|
||||
/** @var IEventDispatcher $dispatcher */
|
||||
$dispatcher = $this->query(IEventDispatcher::class);
|
||||
$dispatcher->dispatchTyped(new UserLoggedOutEvent($user));
|
||||
});
|
||||
$userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) {
|
||||
/** @var $user \OC\User\User */
|
||||
\OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue));
|
||||
|
||||
/** @var IEventDispatcher $dispatcher */
|
||||
$dispatcher = $this->query(IEventDispatcher::class);
|
||||
$dispatcher->dispatchTyped(new UserChangedEvent($user, $feature, $value, $oldValue));
|
||||
});
|
||||
return $userSession;
|
||||
});
|
||||
|
|
|
@ -900,9 +900,9 @@ class Session implements IUserSession, Emitter {
|
|||
* logout the user from the session
|
||||
*/
|
||||
public function logout() {
|
||||
$this->manager->emit('\OC\User', 'logout');
|
||||
$user = $this->getUser();
|
||||
if (!is_null($user)) {
|
||||
$this->manager->emit('\OC\User', 'logout', [$user]);
|
||||
if ($user !== null) {
|
||||
try {
|
||||
$this->tokenProvider->invalidateToken($this->session->getId());
|
||||
} catch (SessionNotAvailableException $ex) {
|
||||
|
@ -914,7 +914,7 @@ class Session implements IUserSession, Emitter {
|
|||
$this->setToken(null);
|
||||
$this->unsetMagicInCookie();
|
||||
$this->session->clear();
|
||||
$this->manager->emit('\OC\User', 'postLogout');
|
||||
$this->manager->emit('\OC\User', 'postLogout', [$user]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
|
||||
*
|
||||
* @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
|
||||
*
|
||||
* @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 OCP\User\Events;
|
||||
|
||||
use OCP\EventDispatcher\Event;
|
||||
use OCP\IUser;
|
||||
|
||||
/**
|
||||
* @since 18.0.0
|
||||
*/
|
||||
class BeforePasswordUpdatedEvent extends Event {
|
||||
|
||||
/** @var IUser */
|
||||
private $user;
|
||||
|
||||
/** @var string */
|
||||
private $password;
|
||||
|
||||
/** @var string|null */
|
||||
private $recoveryPassword;
|
||||
|
||||
/**
|
||||
* @param IUser $user
|
||||
* @param string $password
|
||||
* @param string|null $recoveryPassword
|
||||
* @since 18.0.0
|
||||
*/
|
||||
public function __construct(IUser $user,
|
||||
string $password,
|
||||
string $recoveryPassword = null) {
|
||||
parent::__construct();
|
||||
$this->user = $user;
|
||||
$this->password = $password;
|
||||
$this->recoveryPassword = $recoveryPassword;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return IUser
|
||||
* @since 18.0.0
|
||||
*/
|
||||
public function getUser(): IUser {
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @since 18.0.0
|
||||
*/
|
||||
public function getPassword(): string {
|
||||
return $this->password;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
* @since 18.0.0
|
||||
*/
|
||||
public function getRecoveryPassword(): ?string {
|
||||
return $this->recoveryPassword;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
|
||||
*
|
||||
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
|
||||
*
|
||||
* @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 OCP\User\Events;
|
||||
|
||||
use OCP\EventDispatcher\Event;
|
||||
|
||||
/**
|
||||
* @since 18.0.0
|
||||
*/
|
||||
class BeforeUserCreatedEvent extends Event {
|
||||
|
||||
/** @var string */
|
||||
private $uid;
|
||||
|
||||
/** @var string */
|
||||
private $password;
|
||||
|
||||
/**
|
||||
* @since 18.0.0
|
||||
*/
|
||||
public function __construct(string $uid,
|
||||
string $password) {
|
||||
parent::__construct();
|
||||
$this->uid = $uid;
|
||||
$this->password = $password;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 18.0.0
|
||||
*/
|
||||
public function getUid(): string {
|
||||
return $this->uid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 18.0.0
|
||||
*/
|
||||
public function getPassword(): string {
|
||||
return $this->password;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
|
||||
*
|
||||
* @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
|
||||
*
|
||||
* @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 OCP\User\Events;
|
||||
|
||||
use OCP\EventDispatcher\Event;
|
||||
use OCP\IUser;
|
||||
|
||||
/**
|
||||
* @since 18.0.0
|
||||
*/
|
||||
class BeforeUserDeletedEvent extends Event {
|
||||
|
||||
/** @var IUser */
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* @param IUser $user
|
||||
* @since 18.0.0
|
||||
*/
|
||||
public function __construct(IUser $user) {
|
||||
parent::__construct();
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return IUser
|
||||
* @since 18.0.0
|
||||
*/
|
||||
public function getUser(): IUser {
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* @copyright Copyright (c) 2019, 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 OCP\User\Events;
|
||||
|
||||
use OCP\EventDispatcher\Event;
|
||||
use OCP\IUser;
|
||||
|
||||
/**
|
||||
* @since 18.0.0
|
||||
*/
|
||||
class BeforeUserLoggedInEvent extends Event {
|
||||
|
||||
/** @var IUser */
|
||||
private $username;
|
||||
|
||||
/** @var string */
|
||||
private $password;
|
||||
|
||||
/**
|
||||
* @since 18.0.0
|
||||
*/
|
||||
public function __construct(string $username, string $password) {
|
||||
parent::__construct();
|
||||
$this->username = $username;
|
||||
$this->password = $password;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 18.0.0
|
||||
*/
|
||||
public function getUsername(): IUser {
|
||||
return $this->username;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 18.0.0
|
||||
*/
|
||||
public function getPassword(): string {
|
||||
return $this->password;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* @copyright Copyright (c) 2019, 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 OCP\User\Events;
|
||||
|
||||
use OCP\EventDispatcher\Event;
|
||||
use OCP\IUser;
|
||||
|
||||
/**
|
||||
* @since 18.0.0
|
||||
*/
|
||||
class BeforeUserLoggedInWithCookieEvent extends Event {
|
||||
|
||||
/** @var string */
|
||||
private $username;
|
||||
|
||||
/**
|
||||
* @since 18.0.0
|
||||
*/
|
||||
public function __construct(string $username) {
|
||||
parent::__construct();
|
||||
$this->username = $username;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 18.0.0
|
||||
*/
|
||||
public function getUsername(): string {
|
||||
return $this->username;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* @copyright Copyright (c) 2019, 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 OCP\User\Events;
|
||||
|
||||
use OCP\EventDispatcher\Event;
|
||||
use OCP\IUser;
|
||||
|
||||
/**
|
||||
* @since 18.0.0
|
||||
*/
|
||||
class BeforeUserLoggedOutEvent extends Event {
|
||||
|
||||
/** @var IUser|null */
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* @since 18.0.0
|
||||
*/
|
||||
public function __construct(IUser $user = null) {
|
||||
parent::__construct();
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 18.0.0
|
||||
*/
|
||||
public function getUser(): ?IUser {
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
|
||||
*
|
||||
* @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
|
||||
*
|
||||
* @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 OCP\User\Events;
|
||||
|
||||
use OCP\EventDispatcher\Event;
|
||||
use OCP\IUser;
|
||||
|
||||
/**
|
||||
* @since 18.0.0
|
||||
*/
|
||||
class PasswordUpdatedEvent extends Event {
|
||||
|
||||
/** @var IUser */
|
||||
private $user;
|
||||
|
||||
/** @var string */
|
||||
private $password;
|
||||
|
||||
/** @var string|null */
|
||||
private $recoveryPassword;
|
||||
|
||||
/**
|
||||
* @param IUser $user
|
||||
* @param string $password
|
||||
* @param string|null $recoveryPassword
|
||||
* @since 18.0.0
|
||||
*/
|
||||
public function __construct(IUser $user,
|
||||
string $password,
|
||||
string $recoveryPassword = null) {
|
||||
parent::__construct();
|
||||
$this->user = $user;
|
||||
$this->password = $password;
|
||||
$this->recoveryPassword = $recoveryPassword;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return IUser
|
||||
* @since 18.0.0
|
||||
*/
|
||||
public function getUser(): IUser {
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @since 18.0.0
|
||||
*/
|
||||
public function getPassword(): string {
|
||||
return $this->password;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
* @since 18.0.0
|
||||
*/
|
||||
public function getRecoveryPassword(): ?string {
|
||||
return $this->recoveryPassword;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
|
||||
*
|
||||
* @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
|
||||
*
|
||||
* @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 OCP\User\Events;
|
||||
|
||||
use OCP\EventDispatcher\Event;
|
||||
use OCP\IUser;
|
||||
|
||||
/**
|
||||
* @since 18.0.0
|
||||
*/
|
||||
class UserChangedEvent extends Event {
|
||||
|
||||
/** @var IUser */
|
||||
private $user;
|
||||
|
||||
/** @var string */
|
||||
private $feature;
|
||||
|
||||
/** @var mixed */
|
||||
private $value;
|
||||
|
||||
/** @var mixed */
|
||||
private $oldValue;
|
||||
|
||||
/**
|
||||
* @since 18.0.0
|
||||
*/
|
||||
public function __construct(IUser $user,
|
||||
string $feature,
|
||||
$value,
|
||||
$oldValue = null) {
|
||||
parent::__construct();
|
||||
$this->user = $user;
|
||||
$this->feature = $feature;
|
||||
$this->value = $value;
|
||||
$this->oldValue = $oldValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return IUser
|
||||
* @since 18.0.0
|
||||
*/
|
||||
public function getUser(): IUser {
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @since 18.0.0
|
||||
*/
|
||||
public function getFeature(): string {
|
||||
return $this->feature;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
* @since 18.0.0
|
||||
*/
|
||||
public function getValue() {
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
* @since 18.0.0
|
||||
*/
|
||||
public function getOldValue() {
|
||||
return $this->oldValue;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
|
||||
*
|
||||
* @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
|
||||
*
|
||||
* @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 OCP\User\Events;
|
||||
|
||||
use OCP\EventDispatcher\Event;
|
||||
use OCP\IUser;
|
||||
|
||||
/**
|
||||
* @since 18.0.0
|
||||
*/
|
||||
class UserDeletedEvent extends Event {
|
||||
|
||||
/** @var IUser */
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* @param IUser $user
|
||||
* @since 18.0.0
|
||||
*/
|
||||
public function __construct(IUser $user) {
|
||||
parent::__construct();
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return IUser
|
||||
* @since 18.0.0
|
||||
*/
|
||||
public function getUser(): IUser {
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* @copyright Copyright (c) 2019, Roeland Jago Douma <roeland@famdouma.nl>
|
||||
*
|
||||
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
|
||||
* @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 OCP\User\Events;
|
||||
|
||||
use OCP\EventDispatcher\Event;
|
||||
use OCP\IUser;
|
||||
|
||||
/**
|
||||
* @since 18.0.0
|
||||
*/
|
||||
class UserLoggedInEvent extends Event {
|
||||
|
||||
/** @var IUser */
|
||||
private $user;
|
||||
|
||||
/** @var string */
|
||||
private $password;
|
||||
|
||||
/** @var bool */
|
||||
private $isTokenLogin;
|
||||
|
||||
/**
|
||||
* @since 18.0.0
|
||||
*/
|
||||
public function __construct(IUser $user, string $password, bool $isTokenLogin) {
|
||||
parent::__construct();
|
||||
$this->user = $user;
|
||||
$this->password = $password;
|
||||
$this->isTokenLogin = $isTokenLogin;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 18.0.0
|
||||
*/
|
||||
public function getUser(): IUser {
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 18.0.0
|
||||
*/
|
||||
public function getPassword(): string {
|
||||
return $this->password;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 18.0.0
|
||||
*/
|
||||
public function isTokenLogin(): bool {
|
||||
return $this->isTokenLogin;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* @copyright Copyright (c) 2019, 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 OCP\User\Events;
|
||||
|
||||
use OCP\EventDispatcher\Event;
|
||||
use OCP\IUser;
|
||||
|
||||
/**
|
||||
* @since 18.0.0
|
||||
*/
|
||||
class UserLoggedInWithCookieEvent extends Event {
|
||||
|
||||
/** @var IUser */
|
||||
private $user;
|
||||
|
||||
/** @var string|null */
|
||||
private $password;
|
||||
|
||||
/**
|
||||
* @since 18.0.0
|
||||
*/
|
||||
public function __construct(IUser $user, ?string $password) {
|
||||
parent::__construct();
|
||||
$this->user = $user;
|
||||
$this->password = $password;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 18.0.0
|
||||
*/
|
||||
public function getUser(): IUser {
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 18.0.0
|
||||
*/
|
||||
public function getPassword(): ?string {
|
||||
return $this->password;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* @copyright Copyright (c) 2019, 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 OCP\User\Events;
|
||||
|
||||
use OCP\EventDispatcher\Event;
|
||||
use OCP\IUser;
|
||||
|
||||
/**
|
||||
* @since 18.0.0
|
||||
*/
|
||||
class UserLoggedOutEvent extends Event {
|
||||
|
||||
/** @var IUser|null */
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* @since 18.0.0
|
||||
*/
|
||||
public function __construct(IUser $user = null) {
|
||||
parent::__construct();
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 18.0.0
|
||||
*/
|
||||
public function getUser(): ?IUser {
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue