Clidus / gwl

Video game collection, wishlist and backlog tracker.
https://www.gamingwithlemons.com/
MIT License
18 stars 6 forks source link

Protecting Pages #77

Closed crunchprank closed 8 years ago

crunchprank commented 8 years ago

This is a general question for just my GWL install, and I'm not requesting this to be pushed to the public repo. But if at all possible, I was curious if there was a way to restrict certain pages to only be accessible when being logged in as Admin. Specifically I'd like to lock down the search page. If so, how would I go about doing this? Thanks!

Clidus commented 8 years ago

If you have a look in https://github.com/Clidus/gwl/blob/master/ignition_application/controllers/ignition/admin.php you'll see a good example of how this is done.

Simply add this to the top of the index function in the search controller:

// restricted page
if($this->session->userdata('Admin') != 1)
    show_404();

This will return a 404 page if you don't have admin privileges. :)

crunchprank commented 8 years ago

Perfect! Thanks, once again!

Clidus commented 8 years ago

No problem :)