예제 #1
0
 function facebookLoginAction(Request $request)
 {
     $session = $this->getRequest()->getSession();
     $em = $this->getDoctrine()->getEntityManager();
     $type = 1;
     $status = 1;
     $fbFirstName = $this->get('request')->request->get('fbFirstName');
     $fbLastName = $this->get('request')->request->get('fbLastName');
     $fbUserFullName = $this->get('request')->request->get('fbUserFullName');
     $fbEmail = $this->get('request')->request->get('fbEmail');
     $fbUserprofpic = $this->get('request')->request->get('fbpimage');
     $fbId = $this->get('request')->request->get('user_form_email');
     $session->set('fbId', $fbId);
     $session->set('fbUserprofpic', $fbUserprofpic);
     /*---Start - Add new Facebook User -----*/
     $reviewer = new User();
     $reviewer->setFirstName($fbFirstName);
     $reviewer->setLastName($fbLastName);
     $reviewer->setEmail($fbEmail);
     $reviewer->setImage($fbUserprofpic);
     $reviewer->setfacebookId($fbId);
     $reviewer->setType($type);
     $reviewer->setStatus($status);
     $em->persist($reviewer);
     $em->flush();
     /*---End - Add new Facebook User -----*/
     /*---Start - Facebook LoggedIn -----*/
     $reviewerId = $reviewer->getId();
     $session = $this->getRequest()->getSession();
     $session->set('userId', $reviewerId);
     $session->set('userEmail', $fbEmail);
     $session->set('userName', $fbFirstName);
     $session->set('userType', $type);
     $facebookRepository = $em->getRepository('RAAAdminBundle:User');
     $userLogin = $facebookRepository->findOneBy(array('email' => $fbEmail, 'facebook_id' => $fbId, 'type' => 3, 'status' => 1));
     if ($userLogin) {
         return $this->redirect($this->generateUrl('raa_web_home'));
     }
     /*---End - Facebook LoggedIn -----*/
     return $this->redirect($this->generateUrl('raa_web_home'));
 }