CodeIgniter Forums

Full Version: Double View Problem
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]RogerM[/eluser]
Hey everyone,

I wrote an Auth library and I have a restrict function based on levels.

if the user isn't logged in or doesn't have access to a page, it will load a default view and be done.

It works, but if I use the restrict function and it won't allow them to access the controller, I get the error view and then the controller view below it.

Any thoughts? Thanks

controller is setup like:
Code:
function index()
{
$this->auth->restrict(5);
$this->load->view('account_main');
}

library restrict function
Code:
function restrict($level)
    {
        if($level !==NULL)
        {
            if($this->CI->session->userdata('logged_in') == TRUE)
            {
                if($this->CI->session->userdata('level') >= $level)
                {
                    return TRUE;
                }
                else
                {
                    $this->CI->load->view('access_denied');

                }
            }
            else
            {
                $this->CI->load->view('not_logged_in');

            }
        }
        else
        {
            $this->CI->load->view('access_denied');
        }

El Forum

[eluser]tomcode[/eluser]
You could do :
Code:
function index()
{
    $restricted = $this->auth->restrict(5);

    if( ! $restricted) $this->load->view('account_main');
}

El Forum

[eluser]RogerM[/eluser]
[quote author="tomcode" date="1250050225"]You could do :
Code:
function index()
{
    $restricted = $this->auth->restrict(5);

    if( ! $restricted) $this->load->view('account_main');
}
[/quote]

That is an idea as well.

I decided to format the Error Page and use a show_error()

Thanks!