cacheKey($provider, $nonce), true, now()->addMinutes(10)); return $nonce; } public function consume(SocialProvider $provider, string $nonce, mixed $tokenNonce): bool { $nonceWasIssued = Cache::pull($this->cacheKey($provider, $nonce), false); return is_string($tokenNonce) && hash_equals($nonce, $tokenNonce) && $nonceWasIssued === true; } private function cacheKey(SocialProvider $provider, string $nonce): string { return 'social-auth:'.$provider->value.':nonce:'.hash('sha256', $nonce); } }