コード例 #1
0
 public function indexAction(Request $request)
 {
     if ($request->getMethod() == 'POST') {
         $username = $request->get('username');
         $password = sha1($request->get('password'));
         $em = $this->getDoctrine()->getManager();
         $repository = $em->getRepository("LoginLoginBundle:Users");
         $user = $repository->findOneBy(array('username' => $username, 'password' => $password));
         if ($user) {
             if ($user->getStatus() == 'Active') {
                 $fullname = $user->getFirstname() . " " . $user->getLastname();
                 $session = $this->getRequest()->getSession();
                 $session->clear();
                 $login = new Login();
                 $login->setUsername($user->getUsername());
                 $login->setPassword($password);
                 $login->setRole($user->getRole());
                 $login->setFullname($fullname);
                 $session->set('token', $login);
                 return $this->redirectToRoute('web_dashboard');
                 // return $this->render('webBundle:Default:dashboard.html.twig', array('name' => $user->getUsername(), 'role' => $user->getRole(), 'fullname' => $fullname, 'manageview' => $user->getUserView()));
             } else {
                 return $this->render('LoginLoginBundle:Default:signinV2.html.twig', array('errormsg' => 'Oh snap! You are not an active user'));
             }
         } else {
             return $this->render('LoginLoginBundle:Default:signinV2.html.twig', array('errormsg' => 'Oh snap! Login Failed Try Again'));
         }
     } else {
         return $this->render('LoginLoginBundle:Default:signinV2.html.twig');
     }
 }