Merge pull request #2353 from nextcloud/renew-session-token-remember

copy remember-me value when renewing a session token
This commit is contained in:
Lukas Reschke 2016-11-28 14:04:13 +01:00 committed by GitHub
commit 0cc771ce19
2 changed files with 12 additions and 1 deletions

View file

@ -192,6 +192,7 @@ class DefaultTokenProvider implements IProvider {
$newToken->setName($token->getName()); $newToken->setName($token->getName());
$newToken->setToken($this->hashToken($sessionId)); $newToken->setToken($this->hashToken($sessionId));
$newToken->setType(IToken::TEMPORARY_TOKEN); $newToken->setType(IToken::TEMPORARY_TOKEN);
$newToken->setRemember($token->getRemember());
$newToken->setLastActivity($this->time->getTime()); $newToken->setLastActivity($this->time->getTime());
$this->mapper->insert($newToken); $this->mapper->insert($newToken);
} }

View file

@ -292,6 +292,10 @@ class DefaultTokenProviderTest extends TestCase {
->expects($this->at(3)) ->expects($this->at(3))
->method('getName') ->method('getName')
->willReturn('MyTokenName'); ->willReturn('MyTokenName');
$token
->expects($this->at(3))
->method('getRememberMe')
->willReturn(IToken::DO_NOT_REMEMBER);
$this->config $this->config
->expects($this->exactly(2)) ->expects($this->exactly(2))
->method('getSystemValue') ->method('getSystemValue')
@ -308,6 +312,7 @@ class DefaultTokenProviderTest extends TestCase {
$newToken->setName('MyTokenName'); $newToken->setName('MyTokenName');
$newToken->setToken(hash('sha512', 'newId' . 'MyInstanceSecret')); $newToken->setToken(hash('sha512', 'newId' . 'MyInstanceSecret'));
$newToken->setType(IToken::TEMPORARY_TOKEN); $newToken->setType(IToken::TEMPORARY_TOKEN);
$newToken->setRemember(IToken::DO_NOT_REMEMBER);
$newToken->setLastActivity(1313131); $newToken->setLastActivity(1313131);
$this->mapper $this->mapper
->expects($this->at(1)) ->expects($this->at(1))
@ -342,6 +347,10 @@ class DefaultTokenProviderTest extends TestCase {
->expects($this->at(4)) ->expects($this->at(4))
->method('getName') ->method('getName')
->willReturn('MyTokenName'); ->willReturn('MyTokenName');
$token
->expects($this->at(3))
->method('getRememberMe')
->willReturn(IToken::REMEMBER);
$this->crypto $this->crypto
->expects($this->any(0)) ->expects($this->any(0))
->method('decrypt') ->method('decrypt')
@ -368,12 +377,13 @@ class DefaultTokenProviderTest extends TestCase {
$newToken->setName('MyTokenName'); $newToken->setName('MyTokenName');
$newToken->setToken(hash('sha512', 'newId' . 'MyInstanceSecret')); $newToken->setToken(hash('sha512', 'newId' . 'MyInstanceSecret'));
$newToken->setType(IToken::TEMPORARY_TOKEN); $newToken->setType(IToken::TEMPORARY_TOKEN);
$newToken->setRemember(IToken::REMEMBER);
$newToken->setLastActivity(1313131); $newToken->setLastActivity(1313131);
$newToken->setPassword('EncryptedPassword'); $newToken->setPassword('EncryptedPassword');
$this->mapper $this->mapper
->expects($this->at(1)) ->expects($this->at(1))
->method('insert') ->method('insert')
->with($newToken); ->with($this->equalTo($newToken));
$this->tokenProvider->renewSessionToken('oldId', 'newId'); $this->tokenProvider->renewSessionToken('oldId', 'newId');
} }