/**
  * @inheritDoc
  */
 public function getUser($credentials, UserProviderInterface $userProvider)
 {
     $data = $this->encoder->decode($credentials);
     if (!$data) {
         return null;
     }
     $username = $data['username'];
     return $this->em->getRepository('UserBundle:User')->getUser($username);
 }
Esempio n. 2
0
 /**
  * @throws AccessDeniedException
  * @return array
  * @View()
  */
 public function getUsersAction(Request $request)
 {
     //print_r($request->headers->get("Authorization"));
     $token = new AuthorizationHeaderTokenExtractor("Bearer");
     $token = $token->extract($request);
     $encoder = new JWTEncoder($this->getParameter('jwt_private_key_path'), $this->getParameter('jwt_public_key_path'), $this->getParameter('jwt_key_pass_phrase'));
     $data = $encoder->decode($token);
     print_r($data);
     die;
     if (!$this->get('security.context')->isGranted('ROLE_USER')) {
         throw new AccessDeniedException();
     }
     $users = $this->getDoctrine()->getRepository('sfRestBundle:User')->findAll();
     $view = $this->view($users, 200);
     #->setTemplate("sfRestBundle:Users:getUsers.html.twig")
     #->setTemplateVar('users');
     return $this->handleView($view);
 }