<?php
    $login = new Login();
    if($login->isLogged()){        
        if($controller == 'index'){
            if($login->getRole() === '4'){ header('Location: /Controller/Registro.php');exit;}
            header('Location: /Controller/Home.php');
        }else{
            $acl = new Acl($login->getId());
            if(!$acl->isAllowed($controller,$action)){
                header('Location: /Controller/Home.php');
                exit;
            }
        }
    }else{
        if($controller === 'Registro'){
            if($login->isLoginCorrect(GENERIC_USER, GENERIC_PASSWORD)){
                 header('Location: /Controller/Registro.php');
                exit;
            }          
        }
        
        if($controller != 'index'){
            header('Location: /');
            exit;
        } 
    }