Skip to content

Commit a388b2f

Browse files
authored
Merge pull request #29129 from nextcloud/backport/27886/stable22
[stable22] Keep pw based auth tokens valid when pw-less login happens
2 parents 9163894 + caae37e commit a388b2f

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

lib/private/Authentication/Listeners/UserLoggedInListener.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ public function handle(Event $event): void {
4848
return;
4949
}
5050

51+
// prevent setting an empty pw as result of pw-less-login
52+
if ($event->getPassword() === '') {
53+
return;
54+
}
55+
5156
// If this is already a token login there is nothing to do
5257
if ($event->isTokenLogin()) {
5358
return;

lib/private/Authentication/Token/PublicKeyTokenProvider.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,11 @@ public function markPasswordInvalid(IToken $token, string $tokenId) {
413413
public function updatePasswords(string $uid, string $password) {
414414
$this->cache->clear();
415415

416+
// prevent setting an empty pw as result of pw-less-login
417+
if ($password === '') {
418+
return;
419+
}
420+
416421
// Update the password for all tokens
417422
$tokens = $this->mapper->getTokenByUser($uid);
418423
foreach ($tokens as $t) {

0 commit comments

Comments
 (0)