From d808f9c053fb80b0ec042f12e39f7387ca7821ca Mon Sep 17 00:00:00 2001
From: Christoph Wurst <christoph@winzerhof-wurst.at>
Date: Wed, 11 Dec 2019 09:38:23 +0100
Subject: Add typed events for all user hooks and legacy events

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
---
 .../User/Events/BeforePasswordUpdatedEvent.php     | 82 +++++++++++++++++++
 lib/public/User/Events/BeforeUserCreatedEvent.php  | 66 +++++++++++++++
 lib/public/User/Events/BeforeUserDeletedEvent.php  | 54 +++++++++++++
 lib/public/User/Events/BeforeUserLoggedInEvent.php | 66 +++++++++++++++
 .../Events/BeforeUserLoggedInWithCookieEvent.php   | 55 +++++++++++++
 .../User/Events/BeforeUserLoggedOutEvent.php       | 55 +++++++++++++
 lib/public/User/Events/PasswordUpdatedEvent.php    | 82 +++++++++++++++++++
 lib/public/User/Events/UserChangedEvent.php        | 93 ++++++++++++++++++++++
 lib/public/User/Events/UserDeletedEvent.php        | 54 +++++++++++++
 lib/public/User/Events/UserLoggedInEvent.php       | 77 ++++++++++++++++++
 .../User/Events/UserLoggedInWithCookieEvent.php    | 66 +++++++++++++++
 lib/public/User/Events/UserLoggedOutEvent.php      | 55 +++++++++++++
 12 files changed, 805 insertions(+)
 create mode 100644 lib/public/User/Events/BeforePasswordUpdatedEvent.php
 create mode 100644 lib/public/User/Events/BeforeUserCreatedEvent.php
 create mode 100644 lib/public/User/Events/BeforeUserDeletedEvent.php
 create mode 100644 lib/public/User/Events/BeforeUserLoggedInEvent.php
 create mode 100644 lib/public/User/Events/BeforeUserLoggedInWithCookieEvent.php
 create mode 100644 lib/public/User/Events/BeforeUserLoggedOutEvent.php
 create mode 100644 lib/public/User/Events/PasswordUpdatedEvent.php
 create mode 100644 lib/public/User/Events/UserChangedEvent.php
 create mode 100644 lib/public/User/Events/UserDeletedEvent.php
 create mode 100644 lib/public/User/Events/UserLoggedInEvent.php
 create mode 100644 lib/public/User/Events/UserLoggedInWithCookieEvent.php
 create mode 100644 lib/public/User/Events/UserLoggedOutEvent.php

(limited to 'lib/public')

diff --git a/lib/public/User/Events/BeforePasswordUpdatedEvent.php b/lib/public/User/Events/BeforePasswordUpdatedEvent.php
new file mode 100644
index 00000000000..c40bd92b619
--- /dev/null
+++ b/lib/public/User/Events/BeforePasswordUpdatedEvent.php
@@ -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;
+	}
+
+}
diff --git a/lib/public/User/Events/BeforeUserCreatedEvent.php b/lib/public/User/Events/BeforeUserCreatedEvent.php
new file mode 100644
index 00000000000..1a00a167dbb
--- /dev/null
+++ b/lib/public/User/Events/BeforeUserCreatedEvent.php
@@ -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;
+	}
+
+}
diff --git a/lib/public/User/Events/BeforeUserDeletedEvent.php b/lib/public/User/Events/BeforeUserDeletedEvent.php
new file mode 100644
index 00000000000..b40c498350f
--- /dev/null
+++ b/lib/public/User/Events/BeforeUserDeletedEvent.php
@@ -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;
+	}
+
+}
diff --git a/lib/public/User/Events/BeforeUserLoggedInEvent.php b/lib/public/User/Events/BeforeUserLoggedInEvent.php
new file mode 100644
index 00000000000..8b819478737
--- /dev/null
+++ b/lib/public/User/Events/BeforeUserLoggedInEvent.php
@@ -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;
+	}
+
+}
diff --git a/lib/public/User/Events/BeforeUserLoggedInWithCookieEvent.php b/lib/public/User/Events/BeforeUserLoggedInWithCookieEvent.php
new file mode 100644
index 00000000000..35f9715516b
--- /dev/null
+++ b/lib/public/User/Events/BeforeUserLoggedInWithCookieEvent.php
@@ -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;
+	}
+
+}
diff --git a/lib/public/User/Events/BeforeUserLoggedOutEvent.php b/lib/public/User/Events/BeforeUserLoggedOutEvent.php
new file mode 100644
index 00000000000..a5d617089f7
--- /dev/null
+++ b/lib/public/User/Events/BeforeUserLoggedOutEvent.php
@@ -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;
+	}
+
+}
diff --git a/lib/public/User/Events/PasswordUpdatedEvent.php b/lib/public/User/Events/PasswordUpdatedEvent.php
new file mode 100644
index 00000000000..83b5b0a7bfd
--- /dev/null
+++ b/lib/public/User/Events/PasswordUpdatedEvent.php
@@ -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;
+	}
+
+}
diff --git a/lib/public/User/Events/UserChangedEvent.php b/lib/public/User/Events/UserChangedEvent.php
new file mode 100644
index 00000000000..86b2f439bfb
--- /dev/null
+++ b/lib/public/User/Events/UserChangedEvent.php
@@ -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;
+	}
+
+
+}
diff --git a/lib/public/User/Events/UserDeletedEvent.php b/lib/public/User/Events/UserDeletedEvent.php
new file mode 100644
index 00000000000..284ee35a242
--- /dev/null
+++ b/lib/public/User/Events/UserDeletedEvent.php
@@ -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;
+	}
+
+}
diff --git a/lib/public/User/Events/UserLoggedInEvent.php b/lib/public/User/Events/UserLoggedInEvent.php
new file mode 100644
index 00000000000..8ce83f42308
--- /dev/null
+++ b/lib/public/User/Events/UserLoggedInEvent.php
@@ -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;
+	}
+}
diff --git a/lib/public/User/Events/UserLoggedInWithCookieEvent.php b/lib/public/User/Events/UserLoggedInWithCookieEvent.php
new file mode 100644
index 00000000000..c9848e1cc7d
--- /dev/null
+++ b/lib/public/User/Events/UserLoggedInWithCookieEvent.php
@@ -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;
+	}
+
+}
diff --git a/lib/public/User/Events/UserLoggedOutEvent.php b/lib/public/User/Events/UserLoggedOutEvent.php
new file mode 100644
index 00000000000..14259149533
--- /dev/null
+++ b/lib/public/User/Events/UserLoggedOutEvent.php
@@ -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;
+	}
+
+}
-- 
cgit v1.2.3