CodeIgniter Forums
Athentication classes - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=11)
+--- Thread: Athentication classes (/showthread.php?tid=87231)



Athentication classes - manuel357 - 03-28-2023

Hi, how are you? I will try to explain my problem in english, sorry if not good.
I am upgrading codeigniter to version 4.0 from 3.0, and I face the following problem:
On codeigniter 3 I have an authentication class:
PHP Code:
<?php

 
class Common_Auth_Controller extends CI_Controller {

 public function 
__construct() {

 
parent::__construct();

 
$is_logged_in $this->session->userdata('is_logged_in');
 if(!isset(
$is_logged_in) || $is_logged_in != true)
 {
 echo 
"<center>";
 echo 
"<b>No tienes permisos para acceder a esta seccion. <br> Haga click </b> " anchor(site_url("login"), "aqui"'target="_parent"');
 echo 
"</center>";
 die();
 }
 else if(
$this->session->userdata('id_sesion') != ""//si ya tiene un id de sesion
 
{
 
$this->load->model('sesiones_model');
 
$tipo $this->session->userdata('tipo');
 
 
//se verifica que la sesion actual sea la que esta en la base
 
 
if($tipo!=1)
 {
 if(!
$this->sesiones_model->verificarSesionAbierta($this->session->userdata('id_sesion')))
 {
 
redirect('sesion/cargar_sesion');
 }
 }
 }
 }
 }
?>

That class was in /application/core/ directory so the classes that I have in my controllers directory extends from Common_Auth_Controller to check if the user is logged or not.
But, now in codeigniter 4 I don't have the core directory, I would like to know in which directory I could create the class Common_Auth_Controller

Thanks,
Manuel


RE: Athentication classes - kenjis - 03-28-2023

Any directory if you follow the PSR-4 rules.
https://www.php-fig.org/psr/psr-4/

But many people would use app/Controllers/.