Welcome Guest, Not a member yet? Register   Sign In
User Auth with Private Function
#2

[eluser]Phil Sturgeon[/eluser]
Right k, STOP right there.

That is one nasty way of user authentication. To answer your question, try the code:

Code:
if(!$this->session->userdata('logged_in')) {
      $this->load->view('login');
      exit(); // <-- Add that
    }

But this code is not the way to go. Instead of using this code in _init use it in a hook. In /config/hooks.php add:

Code:
$hook['post_controller_constructor'][] = array(
    'function' => 'grantAccess',
    'filename' => 'grantAccess.php',
    'filepath' => 'hooks',
    );

Enable hooks in /config/config.php

Make a file in /hooks/ called grantAccess.php and make a function the same name.

In that function, put your authorisation code. That will make it load for all controllers!

You could put in an array or a few if's for pages you dont want blocked. For example:

Code:
$class = $CI->uri->router->class;
$method = $CI->uri->router->method;

if(in_array($class, $public_classes)) return;
if(in_array($method, $public_methods)) return;

Something like that.


Messages In This Thread
User Auth with Private Function - by El Forum - 07-01-2007, 06:07 PM
User Auth with Private Function - by El Forum - 07-02-2007, 04:57 AM
User Auth with Private Function - by El Forum - 07-02-2007, 05:28 AM
User Auth with Private Function - by El Forum - 07-02-2007, 09:58 AM
User Auth with Private Function - by El Forum - 07-05-2007, 11:33 PM
User Auth with Private Function - by El Forum - 07-09-2007, 05:16 PM



Theme © iAndrew 2016 - Forum software by © MyBB