aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Petry <vincent@nextcloud.com>2021-10-13 08:39:27 +0200
committerGitHub <noreply@github.com>2021-10-13 08:39:27 +0200
commite229cd3d53aed19c7f5036434b1fdd3967df1ddb (patch)
treeb895febef1fd432e228c5a66d8336c4c0974b8d8
parent5735a55509f93fa0aca5bf4360c2b7601101c616 (diff)
parent4a174617eb822af73b556f9330f557986c1422a7 (diff)
downloadnextcloud-server-e229cd3d53aed19c7f5036434b1fdd3967df1ddb.tar.gz
nextcloud-server-e229cd3d53aed19c7f5036434b1fdd3967df1ddb.zip
Merge pull request #29130 from nextcloud/backport/27886/stable21
[stable21] Keep pw based auth tokens valid when pw-less login happens
-rw-r--r--lib/private/Authentication/Listeners/UserLoggedInListener.php5
-rw-r--r--lib/private/Authentication/Token/PublicKeyTokenProvider.php5
2 files changed, 10 insertions, 0 deletions
diff --git a/lib/private/Authentication/Listeners/UserLoggedInListener.php b/lib/private/Authentication/Listeners/UserLoggedInListener.php
index 711a759fad4..15d34494276 100644
--- a/lib/private/Authentication/Listeners/UserLoggedInListener.php
+++ b/lib/private/Authentication/Listeners/UserLoggedInListener.php
@@ -49,6 +49,11 @@ class UserLoggedInListener implements IEventListener {
return;
}
+ // prevent setting an empty pw as result of pw-less-login
+ if ($event->getPassword() === '') {
+ return;
+ }
+
// If this is already a token login there is nothing to do
if ($event->isTokenLogin()) {
return;
diff --git a/lib/private/Authentication/Token/PublicKeyTokenProvider.php b/lib/private/Authentication/Token/PublicKeyTokenProvider.php
index a293d2a8404..4657a802767 100644
--- a/lib/private/Authentication/Token/PublicKeyTokenProvider.php
+++ b/lib/private/Authentication/Token/PublicKeyTokenProvider.php
@@ -414,6 +414,11 @@ class PublicKeyTokenProvider implements IProvider {
public function updatePasswords(string $uid, string $password) {
$this->cache->clear();
+ // prevent setting an empty pw as result of pw-less-login
+ if ($password === '') {
+ return;
+ }
+
// Update the password for all tokens
$tokens = $this->mapper->getTokenByUser($uid);
foreach ($tokens as $t) {