src/Controller/DefaultController.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\Request;
  5. use Symfony\Component\HttpFoundation\Response;
  6. use Symfony\Component\HttpFoundation\RedirectResponse;
  7. class DefaultController extends AbstractController {
  8.     public function indexAction(Request $request) { 
  9.         $session = $request->getSession();
  10.         $session->start();
  11.         $user = $this->get('security.token_storage')->getToken()->getUser();
  12.         if($user->getChangedPassword()){
  13.             if ($user->getRole()=="ROLE_ADMIN") {
  14.                 //return $this->render('AdminBundle:Default:portadaAdmin.html.twig');
  15.                 return $this -> redirectToRoute('competition_list');
  16.             } else if ($user->getRole()=="ROLE_TUTOR") {   
  17.                 //return $this->render('AdminBundle:Default:portadaTutor.html.twig');
  18.                 return $this -> redirectToRoute('competition_client_list', array('client' => $user->getCliente()->getId()));
  19.             } else if ($user->getRole()=="ROLE_USER") {
  20.                 //return $this->render('AdminBundle:Default:portadaUser.html.twig');
  21.                 return $this -> redirectToRoute('competition_users_list', array("categoryname"=>'all'));
  22.             }else{
  23.                 return $this->redirectToRoute('login');
  24.                 // return $this->redirectToRoute('end_page');
  25.             }
  26.         } else {
  27.             return $this -> redirectToRoute('user_changepassword');
  28.         }
  29.     }
  30.     public function emailView($numb){
  31.         if($numb == 1){
  32.             return $this->render('Emails/registration.html.twig', array('user'=>$this->get('security.token_storage')->getToken()->getUser(), 'password'=>$this->get('App\Controller\UserController')->generateRandomString()));
  33.         } else if($numb == 2){
  34.             return $this->render('Emails/resetPassword.html.twig', array('user'=>$this->get('security.token_storage')->getToken()->getUser(), 'tok'=>$this->get('App\Controller\UserController')->generateRandomString()));
  35.         } else {
  36.             return $this->redirectToRoute('cliente');
  37.         }
  38.     }
  39.     public function endPage(){
  40.         return $this->render('endPage.html.twig');
  41.     }
  42.     public function checkUserBlocked(){
  43.         $user = $this->get('security.token_storage')->getToken()->getUser();
  44.         $fn = file_get_contents(__DIR__ ."/../Security/correos-pepe2.txt");     
  45.         $emailsArray = explode(',', $fn);
  46.         $isBlocked = true;
  47.         foreach ($emailsArray as $ea) {
  48.             if($ea == $user->getEmail()){
  49.                 $isBlocked = false;
  50.             }
  51.         }
  52.         return $isBlocked;
  53.     }
  54. }