<?php
namespace App\Controller;
use App\Controller\UserInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\Routing\Annotation\Route;
class HomeController extends AbstractController{
public function __construct(){
}
/**
* @Route("/", name="home_index")
*/
public function index(Session $session){
if(count($this->get('security.token_storage')->getToken()->getUser()->getClients()) > 0)
$id = $this->get('security.token_storage')->getToken()->getUser()->getClients()[0]->getId();
$role = $this->get('security.token_storage')->getToken()->getUser()->getRoles()[0];
$user = $this->getUser();
$userId = $user->getId();
$resetToken = $this->get('security.token_storage')->getToken()->getUser()->getResetPassword();
$session->set("role", $role);
// 'message' => "You must change your password for more security"
if(!empty($resetToken)) {
$em = $this->getDoctrine()->getManager();
$user->setResetPassword("");
$em->flush();
}
// if($role === "ROLE_PROSPECT" || $role === "ROLE_SKAZE" || $role === "ROLE_ADMIN")
return $this->redirectToRoute('dashboard_index');
// if(!isset($id))
// throw $this->createNotFoundException('This page does not exist');
// return $this->redirectToRoute('dashboard_show', [
// 'id' => $id
// ]);
}
}