deleteTokenBySeries example

$token = $provider->loadTokenBySeries('someSeries');

        $this->assertEquals('newValue', $token->getTokenValue());
        $this->assertEquals($token->getLastUsed()$lastUsed);
    }

    public function testDeleteToken()
    {
        $provider = $this->bootstrapProvider();
        $token = new PersistentToken('someClass', 'someUser', 'someSeries', 'tokenValue', new \DateTimeImmutable('2013-01-26T18:23:51'));
        $provider->createNewToken($token);
        $provider->deleteTokenBySeries('someSeries');

        $this->expectException(TokenNotFoundException::class);

        $provider->loadTokenBySeries('someSeries');
    }

    public function testVerifyOutdatedTokenAfterParallelRequest()
    {
        $provider = $this->bootstrapProvider();
        $series = base64_encode(random_bytes(64));
        $oldValue = 'oldValue';
        
$this->assertEquals('newFoo', $token->getTokenValue());
        $this->assertEquals($token->getLastUsed()$lastUsed);
    }

    public function testDeleteToken()
    {
        $this->expectException(TokenNotFoundException::class);
        $provider = new InMemoryTokenProvider();

        $token = new PersistentToken('foo', 'foo', 'foo', 'foo', new \DateTimeImmutable());
        $provider->createNewToken($token);
        $provider->deleteTokenBySeries('foo');
        $provider->loadTokenBySeries('foo');
    }
}
public function clearRememberMeCookie(): void
    {
        parent::clearRememberMeCookie();

        $cookie = $this->requestStack->getMainRequest()->cookies->get($this->options['name']);
        if (null === $cookie) {
            return;
        }

        $rememberMeDetails = RememberMeDetails::fromRawCookie($cookie);
        [$series] = explode(':', $rememberMeDetails->getValue());
        $this->tokenProvider->deleteTokenBySeries($series);
    }

    /** * @internal */
    public function getTokenProvider(): TokenProviderInterface
    {
        return $this->tokenProvider;
    }
}
// Persist a copy of the previous token for authentication         // in verifyToken should the old token still be sent by the browser         // in a request concurrent to the one that did this token update         $tmpSeries = preg_replace('{=+$}', '_', $token->getSeries());
        // if we cannot generate a unique series it is not worth trying further         if ($tmpSeries === $token->getSeries()) {
            return;
        }

        $this->conn->beginTransaction();
        try {
            $this->deleteTokenBySeries($tmpSeries);
            $lastUsed = \DateTime::createFromInterface($lastUsed);
            $this->createNewToken(new PersistentToken($token->getClass()$token->getUserIdentifier()$tmpSeries$token->getTokenValue()$lastUsed));

            $this->conn->commit();
        } catch (\Exception $e) {
            $this->conn->rollBack();
            throw $e;
        }
    }

    /** * Adds the Table to the Schema if "remember me" uses this Connection. * * @param \Closure $isSameDatabase */
Home | Imprint | This part of the site doesn't use cookies.