From ac8b40b8b12d4bf85bdd6b7ab038f0605c8651d9 Mon Sep 17 00:00:00 2001 From: Lionel Elie Mamane Date: Sat, 20 Jun 2020 11:21:41 +0200 Subject: Return correct loginname in credentials, even when token is invalid or has no password. Returning the uid as loginname is wrong, and leads to problems when these differ. E.g. the getapppassword API was creating app token with the uid as loginname. In a scenario with external authentication (such as LDAP), these tokens were then invalidated next time their underlying password was checked, and systematically ceased to function. Co-authored-by: kesselb for: switch to consistent camelCase Signed-off-by: Lionel Elie Mamane --- lib/public/User/Events/PostLoginEvent.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'lib/public/User') diff --git a/lib/public/User/Events/PostLoginEvent.php b/lib/public/User/Events/PostLoginEvent.php index 15772bfef17..76d9a70aac8 100644 --- a/lib/public/User/Events/PostLoginEvent.php +++ b/lib/public/User/Events/PostLoginEvent.php @@ -38,6 +38,12 @@ class PostLoginEvent extends Event { /** @var IUser */ private $user; + /** + * @since 20.0.0 + * @var string + */ + private $loginName; + /** @var string */ private $password; @@ -47,9 +53,10 @@ class PostLoginEvent extends Event { /** * @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->loginName = $loginName; $this->password = $password; $this->isTokenLogin = $isTokenLogin; } @@ -61,6 +68,13 @@ class PostLoginEvent extends Event { return $this->user; } + /** + * @since 20.0.0 + */ + public function getLoginName(): string { + return $this->loginName; + } + /** * @since 18.0.0 */ -- cgit v1.2.3