/** * Verifies whether the provided token is valid. * * @param CsrfToken $token * @return bool */ public function isTokenValid(CsrfToken $token) { if (!$this->sessionStorage->hasToken()) { return false; } return hash_equals($this->sessionStorage->getToken(), $token->getDecryptedValue()); }
public function testHasTokenWithoutExistingToken() { $this->session->expects($this->once())->method('exists')->with('requesttoken')->willReturn(false); $this->assertSame(false, $this->sessionStorage->hasToken()); }