Skip to content

Commit

Permalink
Merge pull request #27886 from ecsecta/keep_pw_based_authntoken_alive…
Browse files Browse the repository at this point in the history
…_on_pwlesslogin

Keep pw based auth tokens valid when pw-less login happens
  • Loading branch information
LukasReschke authored Jul 27, 2021
2 parents 7652d73 + 251ae10 commit d4352aa
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 @@ -48,6 +48,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 @@ -413,6 +413,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 d4352aa

Please sign in to comment.