/** * Validate a token * * @param string|null $secret * @param string|null $algo * * @return bool */ public function validate($secret = null, $algo = null) { $token = $this->token(); $secret = $secret ?: $this->secret(); $algo = $algo ?: $this->algorithm(); return $this->jwt->validateToken($token, $secret, $algo); }
public function it_throws_an_exception_on_validate_or_fail_if_the_token_is_invalid(JwtDriverInterface $jwt) { $jwt->validateToken('invalid_token', 'secret_123', 'HS256')->willReturn(false); $this->setToken('invalid_token'); $this->shouldThrow(InvalidTokenException::class)->during('validateOrFail'); }