Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

333
Visualizações
Deactivated user redirect to login from ajax request

Can anyone tell me the best practice to check if the user is activated and logged-in? And how can I handle it from ajax request?

If a user is deactivated, redirect to the login page via ajax request on a controller.

I'm making a helper function and calling it in the constructor.

But it not redirecting to the login if the user is deactivated and return "Status Code: 303 See Other"

In controller:

function __construct()
{
    parent::__construct();
    $this->load->helper('auth_helper');
    if (!auth())
    {
        redirect('login/login_panel');
    }
}

Helper function:

function auth()
{

    $CI =& get_instance();

    $user = true;
    if ($CI->session->userdata('user_id')) {
        $CI->load->model('users_model');
        $active = $CI->users_model->getActive($CI->session->userdata('user_id'));
        if ($active->active == '0' || $active->active == null) {
            $user = false;
        }
    } else {
        $user = false;
    }

    return $user;
}
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

try this

function __construct()
{
    parent::__construct();
    $this->load->helper('auth_helper');
    if (!auth())
    {
        header('Location: login/login_panel');
        exit();
    }
}
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda