diff options
Diffstat (limited to 'lib/public/User/Events')
24 files changed, 1163 insertions, 0 deletions
diff --git a/lib/public/User/Events/BeforePasswordUpdatedEvent.php b/lib/public/User/Events/BeforePasswordUpdatedEvent.php new file mode 100644 index 00000000000..489878442b8 --- /dev/null +++ b/lib/public/User/Events/BeforePasswordUpdatedEvent.php @@ -0,0 +1,67 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OCP\User\Events; + +use OCP\EventDispatcher\Event; +use OCP\IUser; + +/** + * Emitted before the user password is updated. + * + * @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; + } +} diff --git a/lib/public/User/Events/BeforeUserCreatedEvent.php b/lib/public/User/Events/BeforeUserCreatedEvent.php new file mode 100644 index 00000000000..62ee32003ce --- /dev/null +++ b/lib/public/User/Events/BeforeUserCreatedEvent.php @@ -0,0 +1,48 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OCP\User\Events; + +use OCP\EventDispatcher\Event; + +/** + * Emitted before a new user is created on the back-end. + * + * @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; + } +} diff --git a/lib/public/User/Events/BeforeUserDeletedEvent.php b/lib/public/User/Events/BeforeUserDeletedEvent.php new file mode 100644 index 00000000000..27bc26a125f --- /dev/null +++ b/lib/public/User/Events/BeforeUserDeletedEvent.php @@ -0,0 +1,37 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +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; + } +} diff --git a/lib/public/User/Events/BeforeUserIdUnassignedEvent.php b/lib/public/User/Events/BeforeUserIdUnassignedEvent.php new file mode 100644 index 00000000000..2dee62521aa --- /dev/null +++ b/lib/public/User/Events/BeforeUserIdUnassignedEvent.php @@ -0,0 +1,34 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +namespace OCP\User\Events; + +use OCP\EventDispatcher\Event; + +/** + * Emitted before removing the mapping between an external user and an internal userid + * @since 31.0.0 + */ +class BeforeUserIdUnassignedEvent extends Event { + /** + * @since 31.0.0 + */ + public function __construct( + private readonly string $userId, + ) { + parent::__construct(); + } + + /** + * @since 31.0.0 + */ + public function getUserId(): string { + return $this->userId; + } +} diff --git a/lib/public/User/Events/BeforeUserLoggedInEvent.php b/lib/public/User/Events/BeforeUserLoggedInEvent.php new file mode 100644 index 00000000000..2c59d57edd7 --- /dev/null +++ b/lib/public/User/Events/BeforeUserLoggedInEvent.php @@ -0,0 +1,60 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +namespace OCP\User\Events; + +use OCP\Authentication\IApacheBackend; +use OCP\EventDispatcher\Event; + +/** + * @since 18.0.0 + */ +class BeforeUserLoggedInEvent extends Event { + private string $username; + private ?string $password; + private ?IApacheBackend $backend; + + /** + * @since 18.0.0 + * @since 26.0.0 password can be null + */ + public function __construct(string $username, ?string $password, ?IApacheBackend $backend = null) { + parent::__construct(); + $this->username = $username; + $this->password = $password; + $this->backend = $backend; + } + + /** + * returns the login name, which must not necessarily match to a user ID + * + * @since 18.0.0 + */ + public function getUsername(): string { + return $this->username; + } + + /** + * @since 18.0.0 + * @since 26.0.0 value can be null + */ + public function getPassword(): ?string { + return $this->password; + } + + /** + * return backend if available (or null) + * + * @return IApacheBackend|null + * @since 26.0.0 + */ + public function getBackend(): ?IApacheBackend { + return $this->backend; + } +} diff --git a/lib/public/User/Events/BeforeUserLoggedInWithCookieEvent.php b/lib/public/User/Events/BeforeUserLoggedInWithCookieEvent.php new file mode 100644 index 00000000000..4e76e0aa36f --- /dev/null +++ b/lib/public/User/Events/BeforeUserLoggedInWithCookieEvent.php @@ -0,0 +1,36 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OCP\User\Events; + +use OCP\EventDispatcher\Event; + +/** + * Emitted before a user is logged in via remember-me cookies. + * + * @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; + } +} diff --git a/lib/public/User/Events/BeforeUserLoggedOutEvent.php b/lib/public/User/Events/BeforeUserLoggedOutEvent.php new file mode 100644 index 00000000000..9b6eb81ab10 --- /dev/null +++ b/lib/public/User/Events/BeforeUserLoggedOutEvent.php @@ -0,0 +1,37 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OCP\User\Events; + +use OCP\EventDispatcher\Event; +use OCP\IUser; + +/** + * Emitted before a user is logged out. + * + * @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; + } +} diff --git a/lib/public/User/Events/OutOfOfficeChangedEvent.php b/lib/public/User/Events/OutOfOfficeChangedEvent.php new file mode 100644 index 00000000000..10865ef7ed5 --- /dev/null +++ b/lib/public/User/Events/OutOfOfficeChangedEvent.php @@ -0,0 +1,36 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +namespace OCP\User\Events; + +use OCP\EventDispatcher\Event; +use OCP\User\IOutOfOfficeData; + +/** + * Emitted when a user's out-of-office period has changed + * + * @since 28.0.0 + */ +class OutOfOfficeChangedEvent extends Event { + /** + * @since 28.0.0 + */ + public function __construct( + private IOutOfOfficeData $data, + ) { + parent::__construct(); + } + + /** + * @since 28.0.0 + */ + public function getData(): IOutOfOfficeData { + return $this->data; + } +} diff --git a/lib/public/User/Events/OutOfOfficeClearedEvent.php b/lib/public/User/Events/OutOfOfficeClearedEvent.php new file mode 100644 index 00000000000..4153ce98ab5 --- /dev/null +++ b/lib/public/User/Events/OutOfOfficeClearedEvent.php @@ -0,0 +1,36 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +namespace OCP\User\Events; + +use OCP\EventDispatcher\Event; +use OCP\User\IOutOfOfficeData; + +/** + * Emitted when a user's out-of-office period is cleared + * + * @since 28.0.0 + */ +class OutOfOfficeClearedEvent extends Event { + /** + * @since 28.0.0 + */ + public function __construct( + private IOutOfOfficeData $data, + ) { + parent::__construct(); + } + + /** + * @since 28.0.0 + */ + public function getData(): IOutOfOfficeData { + return $this->data; + } +} diff --git a/lib/public/User/Events/OutOfOfficeEndedEvent.php b/lib/public/User/Events/OutOfOfficeEndedEvent.php new file mode 100644 index 00000000000..0817994f069 --- /dev/null +++ b/lib/public/User/Events/OutOfOfficeEndedEvent.php @@ -0,0 +1,34 @@ +<?php + +declare(strict_types=1); +/** + * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OCP\User\Events; + +use OCP\EventDispatcher\Event; +use OCP\User\IOutOfOfficeData; + +/** + * Emitted when a user's out-of-office period ended + * + * @since 28.0.0 + */ +class OutOfOfficeEndedEvent extends Event { + /** + * @since 28.0.0 + */ + public function __construct( + private IOutOfOfficeData $data, + ) { + parent::__construct(); + } + + /** + * @since 28.0.0 + */ + public function getData(): IOutOfOfficeData { + return $this->data; + } +} diff --git a/lib/public/User/Events/OutOfOfficeScheduledEvent.php b/lib/public/User/Events/OutOfOfficeScheduledEvent.php new file mode 100644 index 00000000000..f830d2af209 --- /dev/null +++ b/lib/public/User/Events/OutOfOfficeScheduledEvent.php @@ -0,0 +1,36 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +namespace OCP\User\Events; + +use OCP\EventDispatcher\Event; +use OCP\User\IOutOfOfficeData; + +/** + * Emitted when a user's out-of-office period is scheduled + * + * @since 28.0.0 + */ +class OutOfOfficeScheduledEvent extends Event { + /** + * @since 28.0.0 + */ + public function __construct( + private IOutOfOfficeData $data, + ) { + parent::__construct(); + } + + /** + * @since 28.0.0 + */ + public function getData(): IOutOfOfficeData { + return $this->data; + } +} diff --git a/lib/public/User/Events/OutOfOfficeStartedEvent.php b/lib/public/User/Events/OutOfOfficeStartedEvent.php new file mode 100644 index 00000000000..1b5c69b3cfb --- /dev/null +++ b/lib/public/User/Events/OutOfOfficeStartedEvent.php @@ -0,0 +1,34 @@ +<?php + +declare(strict_types=1); +/** + * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OCP\User\Events; + +use OCP\EventDispatcher\Event; +use OCP\User\IOutOfOfficeData; + +/** + * Emitted when a user's out-of-office period started + * + * @since 28.0.0 + */ +class OutOfOfficeStartedEvent extends Event { + /** + * @since 28.0.0 + */ + public function __construct( + private IOutOfOfficeData $data, + ) { + parent::__construct(); + } + + /** + * @since 28.0.0 + */ + public function getData(): IOutOfOfficeData { + return $this->data; + } +} diff --git a/lib/public/User/Events/PasswordUpdatedEvent.php b/lib/public/User/Events/PasswordUpdatedEvent.php new file mode 100644 index 00000000000..d3fd8f078fe --- /dev/null +++ b/lib/public/User/Events/PasswordUpdatedEvent.php @@ -0,0 +1,74 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OCP\User\Events; + +use OCP\EventDispatcher\Event; +use OCP\IUser; + +/** + * Emitted when the user password has been updated. + * + * @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; + } + + /** + * @since 31.0.0 + */ + public function getUid(): string { + return $this->user->getUID(); + } + + /** + * @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; + } +} diff --git a/lib/public/User/Events/PostLoginEvent.php b/lib/public/User/Events/PostLoginEvent.php new file mode 100644 index 00000000000..0a552ef755b --- /dev/null +++ b/lib/public/User/Events/PostLoginEvent.php @@ -0,0 +1,71 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OCP\User\Events; + +use OCP\EventDispatcher\Event; +use OCP\IUser; + +/** + * @since 18.0.0 + */ +class PostLoginEvent extends Event { + /** @var IUser */ + private $user; + + /** + * @since 20.0.0 + * @var string + */ + private $loginName; + + /** @var string */ + private $password; + + /** @var bool */ + private $isTokenLogin; + + /** + * @since 18.0.0 + */ + public function __construct(IUser $user, string $loginName, string $password, bool $isTokenLogin) { + parent::__construct(); + $this->user = $user; + $this->loginName = $loginName; + $this->password = $password; + $this->isTokenLogin = $isTokenLogin; + } + + /** + * @since 18.0.0 + */ + public function getUser(): IUser { + return $this->user; + } + + /** + * @since 20.0.0 + */ + public function getLoginName(): string { + return $this->loginName; + } + + /** + * @since 18.0.0 + */ + public function getPassword(): string { + return $this->password; + } + + /** + * @since 18.0.0 + */ + public function isTokenLogin(): bool { + return $this->isTokenLogin; + } +} diff --git a/lib/public/User/Events/UserChangedEvent.php b/lib/public/User/Events/UserChangedEvent.php new file mode 100644 index 00000000000..f71fb17fff0 --- /dev/null +++ b/lib/public/User/Events/UserChangedEvent.php @@ -0,0 +1,70 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OCP\User\Events; + +use OCP\EventDispatcher\Event; +use OCP\IUser; + +/** + * @since 18.0.0 + */ +class UserChangedEvent extends Event { + private IUser $user; + private string $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; + } +} diff --git a/lib/public/User/Events/UserCreatedEvent.php b/lib/public/User/Events/UserCreatedEvent.php new file mode 100644 index 00000000000..46b990206c0 --- /dev/null +++ b/lib/public/User/Events/UserCreatedEvent.php @@ -0,0 +1,56 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OCP\User\Events; + +use OCP\EventDispatcher\Event; +use OCP\IUser; + +/** + * Emitted when a new user has been created on the back-end. + * + * @since 18.0.0 + */ +class UserCreatedEvent extends Event { + /** @var IUser */ + private $user; + + /** @var string */ + 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 getUid(): string { + return $this->user->getUID(); + } + + /** + * @since 18.0.0 + */ + public function getPassword(): string { + return $this->password; + } +} diff --git a/lib/public/User/Events/UserDeletedEvent.php b/lib/public/User/Events/UserDeletedEvent.php new file mode 100644 index 00000000000..9b74ff96063 --- /dev/null +++ b/lib/public/User/Events/UserDeletedEvent.php @@ -0,0 +1,44 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +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; + } + + /** + * @since 31.0.0 + */ + public function getUid(): string { + return $this->user->getUID(); + } +} diff --git a/lib/public/User/Events/UserFirstTimeLoggedInEvent.php b/lib/public/User/Events/UserFirstTimeLoggedInEvent.php new file mode 100644 index 00000000000..08f7aacb1c2 --- /dev/null +++ b/lib/public/User/Events/UserFirstTimeLoggedInEvent.php @@ -0,0 +1,33 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OCP\User\Events; + +use OCP\EventDispatcher\Event; +use OCP\IUser; + +/** + * @since 28.0.0 + */ +class UserFirstTimeLoggedInEvent extends Event { + /** + * @since 28.0.0 + */ + public function __construct( + private IUser $user, + ) { + parent::__construct(); + } + + /** + * @since 28.0.0 + */ + public function getUser(): IUser { + return $this->user; + } +} diff --git a/lib/public/User/Events/UserIdAssignedEvent.php b/lib/public/User/Events/UserIdAssignedEvent.php new file mode 100644 index 00000000000..829bd50c0d0 --- /dev/null +++ b/lib/public/User/Events/UserIdAssignedEvent.php @@ -0,0 +1,34 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +namespace OCP\User\Events; + +use OCP\EventDispatcher\Event; + +/** + * Emitted by backends (like user_ldap) when a user created externally is mapped for the first time and assigned a userid + * @since 31.0.0 + */ +class UserIdAssignedEvent extends Event { + /** + * @since 31.0.0 + */ + public function __construct( + private readonly string $userId, + ) { + parent::__construct(); + } + + /** + * @since 31.0.0 + */ + public function getUserId(): string { + return $this->userId; + } +} diff --git a/lib/public/User/Events/UserIdUnassignedEvent.php b/lib/public/User/Events/UserIdUnassignedEvent.php new file mode 100644 index 00000000000..128648a0753 --- /dev/null +++ b/lib/public/User/Events/UserIdUnassignedEvent.php @@ -0,0 +1,34 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +namespace OCP\User\Events; + +use OCP\EventDispatcher\Event; + +/** + * Emitted after removing the mapping between an external user and an internal userid + * @since 31.0.0 + */ +class UserIdUnassignedEvent extends Event { + /** + * @since 31.0.0 + */ + public function __construct( + private readonly string $userId, + ) { + parent::__construct(); + } + + /** + * @since 31.0.0 + */ + public function getUserId(): string { + return $this->userId; + } +} diff --git a/lib/public/User/Events/UserLiveStatusEvent.php b/lib/public/User/Events/UserLiveStatusEvent.php new file mode 100644 index 00000000000..b1f4c9c1d75 --- /dev/null +++ b/lib/public/User/Events/UserLiveStatusEvent.php @@ -0,0 +1,92 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OCP\User\Events; + +use OCP\EventDispatcher\Event; +use OCP\IUser; +use OCP\UserStatus\IUserStatus; + +/** + * @since 20.0.0 + */ +class UserLiveStatusEvent extends Event { + /** + * @var string + * @since 20.0.0 + */ + public const STATUS_ONLINE = 'online'; + + /** + * @var string + * @since 20.0.0 + */ + public const STATUS_AWAY = 'away'; + + /** + * @var string + * @since 20.0.0 + */ + public const STATUS_OFFLINE = 'offline'; + + private IUser $user; + private string $status; + private int $timestamp; + private ?IUserStatus $userStatus = null; + + /** + * @since 20.0.0 + */ + public function __construct(IUser $user, + string $status, + int $timestamp) { + parent::__construct(); + $this->user = $user; + $this->status = $status; + $this->timestamp = $timestamp; + } + + /** + * @return IUser + * @since 20.0.0 + */ + public function getUser(): IUser { + return $this->user; + } + + /** + * @return string + * @since 20.0.0 + */ + public function getStatus(): string { + return $this->status; + } + + /** + * @return int + * @since 20.0.0 + */ + public function getTimestamp(): int { + return $this->timestamp; + } + + /** + * Get the user status that might be available after processing the event + * @since 24.0.0 + */ + public function getUserStatus(): ?IUserStatus { + return $this->userStatus; + } + + /** + * @since 24.0.0 + */ + public function setUserStatus(IUserStatus $userStatus) { + $this->userStatus = $userStatus; + } +} diff --git a/lib/public/User/Events/UserLoggedInEvent.php b/lib/public/User/Events/UserLoggedInEvent.php new file mode 100644 index 00000000000..53f61073a59 --- /dev/null +++ b/lib/public/User/Events/UserLoggedInEvent.php @@ -0,0 +1,75 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +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|null */ + private $password; + + /** @var bool */ + private $isTokenLogin; + + /** @var string */ + private $loginName; + + /** + * @since 18.0.0 + */ + 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; + } + + /** + * @since 18.0.0 + */ + public function getUser(): IUser { + return $this->user; + } + + /** + * @since 31.0.0 + */ + public function getUid(): string { + return $this->user->getUID(); + } + + /** + * @since 21.0.0 + */ + public function getLoginName(): string { + return $this->loginName; + } + + /** + * @since 18.0.0 + */ + public function getPassword(): ?string { + return $this->password; + } + + /** + * @since 18.0.0 + */ + public function isTokenLogin(): bool { + return $this->isTokenLogin; + } +} diff --git a/lib/public/User/Events/UserLoggedInWithCookieEvent.php b/lib/public/User/Events/UserLoggedInWithCookieEvent.php new file mode 100644 index 00000000000..6f9def0df7e --- /dev/null +++ b/lib/public/User/Events/UserLoggedInWithCookieEvent.php @@ -0,0 +1,48 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OCP\User\Events; + +use OCP\EventDispatcher\Event; +use OCP\IUser; + +/** + * Emitted when a user has been successfully logged in via remember-me cookies. + * + * @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; + } +} diff --git a/lib/public/User/Events/UserLoggedOutEvent.php b/lib/public/User/Events/UserLoggedOutEvent.php new file mode 100644 index 00000000000..dbdd6d78703 --- /dev/null +++ b/lib/public/User/Events/UserLoggedOutEvent.php @@ -0,0 +1,37 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OCP\User\Events; + +use OCP\EventDispatcher\Event; +use OCP\IUser; + +/** + * Emitted when a user has been logged out successfully. + * + * @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; + } +} |