Welcome Guest, Not a member yet? Register   Sign In
Setting up ion_auth
#1

[eluser]Unknown[/eluser]
New here, hope this isn't too obvious.

I've had a look at the documentation but can't really get my head around this... new to MVC as well which doesn't help.

I just want to stick up a login page and deny access to all other pages unless logged in. Do I have to put a bit of code on every controller? What is the best way to do this?

Although the ion auth documentation is fairly good, a lot of the googled advice I can find refers to older versions and now I'm just confused.
#2

[eluser]srpurdy[/eluser]
[quote author="doncuan" date="1346219612"]New here, hope this isn't too obvious.

I've had a look at the documentation but can't really get my head around this... new to MVC as well which doesn't help.

I just want to stick up a login page and deny access to all other pages unless logged in. Do I have to put a bit of code on every controller? What is the best way to do this?

Although the ion auth documentation is fairly good, a lot of the googled advice I can find refers to older versions and now I'm just confused.[/quote]

Yes pretty much. You want to protect a controller you can put something like
Code:
if (!$this->ion_auth->logged_in())
  {
   //redirect them to the login page
   redirect('auth/login', 'refresh');
  }

you'd put that in the constructor if you want to protect the entire controller. Or you can protect specific functions, and for admin stuff you would use

$this->ion_auth->is_admin()




Theme © iAndrew 2016 - Forum software by © MyBB