From cd457cc68bf72b402b7757d4f039af48f1ac3d3f Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Wed, 3 Feb 2021 11:13:25 +0100 Subject: [PATCH] Always renew apppasswords on login Else you can end up that you renewed your password (LDAP for example). But they still don't work because you did not use them before you logged in. Signed-off-by: Roeland Jago Douma --- .../Token/PublicKeyTokenProvider.php | 5 ----- .../Token/PublicKeyTokenProviderTest.php | 18 +----------------- 2 files changed, 1 insertion(+), 22 deletions(-) diff --git a/lib/private/Authentication/Token/PublicKeyTokenProvider.php b/lib/private/Authentication/Token/PublicKeyTokenProvider.php index 38551e63b872c..a293d2a840424 100644 --- a/lib/private/Authentication/Token/PublicKeyTokenProvider.php +++ b/lib/private/Authentication/Token/PublicKeyTokenProvider.php @@ -414,11 +414,6 @@ public function markPasswordInvalid(IToken $token, string $tokenId) { public function updatePasswords(string $uid, string $password) { $this->cache->clear(); - if (!$this->mapper->hasExpiredTokens($uid)) { - // Nothing to do here - return; - } - // Update the password for all tokens $tokens = $this->mapper->getTokenByUser($uid); foreach ($tokens as $t) { diff --git a/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php b/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php index 04e0fdb527e67..f27100b5d781c 100644 --- a/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php +++ b/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php @@ -548,8 +548,7 @@ public function testUpdatePasswords() { IToken::PERMANENT_TOKEN, IToken::REMEMBER); - $this->mapper->expects($this->once()) - ->method('hasExpiredTokens') + $this->mapper->method('hasExpiredTokens') ->with($uid) ->willReturn(true); $this->mapper->expects($this->once()) @@ -564,19 +563,4 @@ public function testUpdatePasswords() { $this->tokenProvider->updatePasswords($uid, 'bar2'); } - - public function testUpdatePasswordsNotRequired() { - $uid = 'myUID'; - - $this->mapper->expects($this->once()) - ->method('hasExpiredTokens') - ->with($uid) - ->willReturn(false); - $this->mapper->expects($this->never()) - ->method('getTokenByUser'); - $this->mapper->expects($this->never()) - ->method('update'); - - $this->tokenProvider->updatePasswords($uid, 'bar2'); - } }