/** * Get the payload from the current token * * @param string|null $path dot syntax to query for specific data * @param string|null $secret * @param string|null $algo * * @return array */ public function payload($path = null, $secret = null, $algo = null) { $token = $this->token(); $secret = $secret ?: $this->secret(); $algo = $algo ?: $this->algorithm(); $payload = $this->jwt->decodeToken($token, $secret, $algo); return $this->queryPayload($payload, $path); }
public function it_gets_the_payload_data_from_the_provided_dot_path(JwtDriverInterface $jwt) { $jwt->decodeToken('token_123', 'secret_123', 'HS256')->willReturn(['foo' => 'bar', 'context' => ['some' => 'data']]); $this->setToken('token_123'); $this->payload('foo')->shouldReturn('bar'); $this->payload('context')->shouldReturn(['some' => 'data']); $this->payload('context.some')->shouldReturn('data'); }