public function authenticate(TokenInterface $token) { $user = $this->userProvider->loadUserByUsername($token->getUsername()); if ($user) { $authenticatedToken = new FbUserToken($user->getRoles()); $authenticatedToken->setUser($user); return $authenticatedToken; } throw new AuthenticationException('The Facebook authentication failed.'); }
public function handle(GetResponseEvent $event) { $request = $event->getRequest(); if (null !== $this->securityContext->getToken()) { return; } $cookie = $this->getFacebookCookie(); if ($cookie) { $token = new FbUserToken(); $token->setAccessToken($cookie['access_token']); $content = @file_get_contents('https://graph.facebook.com/me?access_token=' . $token->getAccessToken()); if ($content) { $userData = json_decode($content); $user = new FbUser($userData); $token->setUser($user); $this->securityContext->setToken($token); } } }