]> source.dussan.org Git - nextcloud-server.git/commitdiff
copy remember-me value when renewing a session token 2353/head
authorChristoph Wurst <christoph@winzerhof-wurst.at>
Sun, 27 Nov 2016 13:19:57 +0000 (14:19 +0100)
committerChristoph Wurst <christoph@winzerhof-wurst.at>
Sun, 27 Nov 2016 13:19:57 +0000 (14:19 +0100)
On renew, a session token is duplicated. For some reason we did
not copy over the remember-me attribute value. Hence, the new token
was deleted too early in the background job and remember-me did
not work properly.

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
lib/private/Authentication/Token/DefaultTokenProvider.php
tests/lib/Authentication/Token/DefaultTokenProviderTest.php

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