summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorLouis <6653109+artonge@users.noreply.github.com>2022-05-16 12:38:49 +0200
committerGitHub <noreply@github.com>2022-05-16 12:38:49 +0200
commit259b2806bc77d6e46bd37d532bd3af3f971ef5f6 (patch)
tree008a10d4d65db8dfbaf0a86f28da78746ea1e8ee /apps
parente700c3cd33d540e8148f7a5c911bf20f030e69fc (diff)
parent816e7827f0d60e78f112ff9a3c6dfc90facc638b (diff)
downloadnextcloud-server-259b2806bc77d6e46bd37d532bd3af3f971ef5f6.tar.gz
nextcloud-server-259b2806bc77d6e46bd37d532bd3af3f971ef5f6.zip
Merge pull request #32016 from nextcloud/fix/PasswordUpdatedEvent_handling
Use stored user for PasswordUpdatedEvent
Diffstat (limited to 'apps')
-rw-r--r--apps/files_external/lib/Listener/StorePasswordListener.php28
1 files changed, 18 insertions, 10 deletions
diff --git a/apps/files_external/lib/Listener/StorePasswordListener.php b/apps/files_external/lib/Listener/StorePasswordListener.php
index bd0c4dc1ffd..66232a78a93 100644
--- a/apps/files_external/lib/Listener/StorePasswordListener.php
+++ b/apps/files_external/lib/Listener/StorePasswordListener.php
@@ -50,19 +50,27 @@ class StorePasswordListener implements IEventListener {
return;
}
- $stored = $this->credentialsManager->retrieve($event->getUser()->getUID(), LoginCredentials::CREDENTIALS_IDENTIFIER);
- $update = isset($stored['password']) && $stored['password'] !== $event->getPassword();
- if (!$update && $event instanceof UserLoggedInEvent) {
- $update = isset($stored['user']) && $stored['user'] !== $event->getLoginName();
+ $storedCredentials = $this->credentialsManager->retrieve($event->getUser()->getUID(), LoginCredentials::CREDENTIALS_IDENTIFIER);
+
+ if (!$storedCredentials) {
+ return;
+ }
+
+ $newCredentials = $storedCredentials;
+ $shouldUpdate = false;
+
+ if (isset($storedCredentials['password']) && $storedCredentials['password'] !== $event->getPassword()) {
+ $shouldUpdate = true;
+ $newCredentials['password'] = $event->getPassword();
}
- if ($stored && $update) {
- $credentials = [
- 'user' => $event->getLoginName(),
- 'password' => $event->getPassword()
- ];
+ if (isset($storedCredentials['user']) && $event instanceof UserLoggedInEvent && $storedCredentials['user'] !== $event->getLoginName()) {
+ $shouldUpdate = true;
+ $newCredentials['user'] = $event->getLoginName();
+ }
- $this->credentialsManager->store($event->getUser()->getUID(), LoginCredentials::CREDENTIALS_IDENTIFIER, $credentials);
+ if ($shouldUpdate) {
+ $this->credentialsManager->store($event->getUser()->getUID(), LoginCredentials::CREDENTIALS_IDENTIFIER, $newCredentials);
}
}
}