Skip to content

Commit

Permalink
Merge pull request #33225 from nextcloud/fix/handle-one-time-passwords
Browse files Browse the repository at this point in the history
Handle one time password better
  • Loading branch information
CarlSchwan authored Jul 29, 2022
2 parents 532ea00 + 702445b commit 952acd4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ public function updatePasswords(string $uid, string $password) {
$this->cache->clear();

// prevent setting an empty pw as result of pw-less-login
if ($password === '') {
if ($password === '' || !$this->config->getSystemValueBool('auth.storeCryptedPassword', true)) {
return;
}

Expand Down
10 changes: 9 additions & 1 deletion tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function testGenerateToken() {
$this->assertSame($password, $this->tokenProvider->getPassword($actual, $token));
}

public function testGenerateTokenNoPassword() {
public function testGenerateTokenNoPassword(): void {
$token = 'token';
$uid = 'user';
$user = 'User';
Expand Down Expand Up @@ -171,6 +171,10 @@ public function testUpdateToken() {
->method('updateActivity')
->with($tk, $this->time);
$tk->setLastActivity($this->time - 200);
$this->config->method('getSystemValueBool')
->willReturnMap([
['auth.storeCryptedPassword', true, true],
]);

$this->tokenProvider->updateTokenActivity($tk);

Expand Down Expand Up @@ -578,6 +582,10 @@ public function testUpdatePasswords() {
'random2',
IToken::PERMANENT_TOKEN,
IToken::REMEMBER);
$this->config->method('getSystemValueBool')
->willReturnMap([
['auth.storeCryptedPassword', true, true],
]);

$this->mapper->method('hasExpiredTokens')
->with($uid)
Expand Down

0 comments on commit 952acd4

Please sign in to comment.