]> source.dussan.org Git - nextcloud-server.git/commitdiff
Do not override stored credentials when login in with SAML 37901/head
authorLouis Chemineau <louis@chmn.me>
Thu, 13 Apr 2023 16:05:37 +0000 (18:05 +0200)
committerLouis (Rebase PR Action) <artonge@users.noreply.github.com>
Wed, 26 Apr 2023 07:35:06 +0000 (07:35 +0000)
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 <louis@chmn.me>
apps/files_external/lib/Listener/StorePasswordListener.php

index 66232a78a9301a5671fcaebff2928efecdc0e4b8..f5820eff52c75041b8a7376bd58910b77983402c 100644 (file)
@@ -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();
                }