From 30e78f3f61b795d7cd1589f1d32b3c75e2b89f28 Mon Sep 17 00:00:00 2001 From: Louis Chemineau Date: Thu, 13 Apr 2023 18:05:37 +0200 Subject: [PATCH] Do not override stored credentials when login in with SAML When login in with SAML, the password from `$event->getPassword()` is `null`. This PR makes sure that this `null` value won't be used to override the stored password even though it is different. This PR also allow for the password and user to be updated even though they were not set before. Signed-off-by: Louis Chemineau --- apps/files_external/lib/Listener/StorePasswordListener.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/files_external/lib/Listener/StorePasswordListener.php b/apps/files_external/lib/Listener/StorePasswordListener.php index 66232a78a93..f5820eff52c 100644 --- a/apps/files_external/lib/Listener/StorePasswordListener.php +++ b/apps/files_external/lib/Listener/StorePasswordListener.php @@ -59,12 +59,12 @@ class StorePasswordListener implements IEventListener { $newCredentials = $storedCredentials; $shouldUpdate = false; - if (isset($storedCredentials['password']) && $storedCredentials['password'] !== $event->getPassword()) { + if (($storedCredentials['password'] ?? null) !== $event->getPassword() && $event->getPassword() !== null) { $shouldUpdate = true; $newCredentials['password'] = $event->getPassword(); } - if (isset($storedCredentials['user']) && $event instanceof UserLoggedInEvent && $storedCredentials['user'] !== $event->getLoginName()) { + if ($event instanceof UserLoggedInEvent && ($storedCredentials['user'] ?? null) !== $event->getLoginName()) { $shouldUpdate = true; $newCredentials['user'] = $event->getLoginName(); } -- 2.39.5