Skip to content

Commit

Permalink
Merge pull request #25460 from nextcloud/fix/apppassword/always_renew
Browse files Browse the repository at this point in the history
Always renew apppasswords on login
  • Loading branch information
rullzer authored Feb 10, 2021
2 parents d0cf4e2 + cd457cc commit 7bacd71
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 22 deletions.
5 changes: 0 additions & 5 deletions lib/private/Authentication/Token/PublicKeyTokenProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
18 changes: 1 addition & 17 deletions tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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');
}
}

0 comments on commit 7bacd71

Please sign in to comment.