Skip to content

Commit

Permalink
Merge pull request #29130 from nextcloud/backport/27886/stable21
Browse files Browse the repository at this point in the history
[stable21] Keep pw based auth tokens valid when pw-less login happens
  • Loading branch information
PVince81 authored Oct 13, 2021
2 parents 5735a55 + 4a17461 commit e229cd3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/private/Authentication/Listeners/UserLoggedInListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ public function handle(Event $event): void {
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;
Expand Down
5 changes: 5 additions & 0 deletions lib/private/Authentication/Token/PublicKeyTokenProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,11 @@ public function markPasswordInvalid(IToken $token, string $tokenId) {
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) {
Expand Down

0 comments on commit e229cd3

Please sign in to comment.