mirror of
				https://github.com/elyby/oauth2-server.git
				synced 2025-05-31 14:12:07 +05:30 
			
		
		
		
	prevent double persist of token when doing refresh grant
This commit is contained in:
		@@ -74,8 +74,6 @@ class RefreshTokenGrant extends AbstractGrant
 | 
			
		||||
        // Issue and persist new tokens
 | 
			
		||||
        $accessToken = $this->issueAccessToken($accessTokenTTL, $client, $oldRefreshToken['user_id'], $scopes);
 | 
			
		||||
        $refreshToken = $this->issueRefreshToken($accessToken);
 | 
			
		||||
        $this->accessTokenRepository->persistNewAccessToken($accessToken);
 | 
			
		||||
        $this->refreshTokenRepository->persistNewRefreshToken($refreshToken);
 | 
			
		||||
 | 
			
		||||
        // Inject tokens into response
 | 
			
		||||
        $responseType->setAccessToken($accessToken);
 | 
			
		||||
 
 | 
			
		||||
@@ -48,10 +48,14 @@ class RefreshTokenGrantTest extends \PHPUnit_Framework_TestCase
 | 
			
		||||
        $scopeRepositoryMock->method('getScopeEntityByIdentifier')->willReturn($scopeEntity);
 | 
			
		||||
 | 
			
		||||
        $accessTokenRepositoryMock = $this->getMockBuilder(AccessTokenRepositoryInterface::class)->getMock();
 | 
			
		||||
        $accessTokenRepositoryMock->method('persistNewAccessToken')->willReturnSelf();
 | 
			
		||||
        $accessTokenRepositoryMock
 | 
			
		||||
            ->expects($this->once())
 | 
			
		||||
            ->method('persistNewAccessToken')->willReturnSelf();
 | 
			
		||||
 | 
			
		||||
        $refreshTokenRepositoryMock = $this->getMockBuilder(RefreshTokenRepositoryInterface::class)->getMock();
 | 
			
		||||
        $refreshTokenRepositoryMock->method('persistNewRefreshToken')->willReturnSelf();
 | 
			
		||||
        $refreshTokenRepositoryMock
 | 
			
		||||
            ->expects($this->once())
 | 
			
		||||
            ->method('persistNewRefreshToken')->willReturnSelf();
 | 
			
		||||
 | 
			
		||||
        $grant = new RefreshTokenGrant($refreshTokenRepositoryMock);
 | 
			
		||||
        $grant->setClientRepository($clientRepositoryMock);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user