Welcome Guest, Not a member yet? Register   Sign In
Ion Auth - Lightweight Auth System based on Redux Auth 2

[eluser]xatrix[/eluser]
Once the user is logged in, here's how to redirect him to the page that required auth.

In Ion_Auth.php
Code:
public function logged_in()
    {
        $this->ci->session->set_flashdata('referrer', current_url());
        $identity = $this->ci->config->item('identity', 'ion_auth');

        return (bool) $this->ci->session->userdata($identity);
    }

In Auth.php

Code:
if ($this->ion_auth->login($this->input->post('email'), $this->input->post('password'), $remember))
            { //if the login is successful
                //redirect them from whence they came
                $this->session->set_flashdata('message', $this->ion_auth->messages());
                redirect($this->session->flashdata('referrer'));
            }
}

Basically it will only set flashdata when it has to check if the user is logged in, and redirect when he is.

Also in your Auth.php, loading a view counts as a server request. So before you load the login view, tell CI to keep the data:
Code:
$this->session->keep_flashdata('referrer');
$this->load->view('auth/login', $this->data);

* however, I'm not sure what happens if you call logged_in multiple times. There must be some way to check that flashdata has been set, so that the same key isn't overwritten (is that even possible?) and reduce code crap. Any ideas?


Messages In This Thread
Ion Auth - Lightweight Auth System based on Redux Auth 2 - by El Forum - 12-18-2010, 04:33 AM



Theme © iAndrew 2016 - Forum software by © MyBB