Alex Posted February 27, 2011 Report Posted February 27, 2011 how can i restrict access to my downloads page only to logged in pilots. i tried this <?php if(!Auth::LoggedIn()) { ?> <li><a href="<?php echo SITE_URL ?>/index.php/registration"><strong>Register</strong></a></li> <li><a href="<?php echo url('/login'); ?>"><strong>Pilot Log In</strong></a></li> <?php } else { ?> <li><a href="<?php echo SITE_URL ?>/index.php/downloads"><strong>Downloads</strong></a></li> <?php but that doesnt work Quote
James142 Posted February 27, 2011 Report Posted February 27, 2011 how can i restrict access to my downloads page only to logged in pilots. i tried this <?php if(!Auth::LoggedIn()) { ?> <li><a href="<?php echo SITE_URL ?>/index.php/registration"><strong>Register</strong></a></li> <li><a href="<?php echo url('/login'); ?>"><strong>Pilot Log In</strong></a></li> <?php } else { ?> <li><a href="<?php echo SITE_URL ?>/index.php/downloads"><strong>Downloads</strong></a></li> <?php but that doesnt work Switch the <li><a href="<?php echo SITE_URL ?>/index.php/registration"><strong>Register</strong></a></li> <li><a href="<?php echo url('/login'); ?>"><strong>Pilot Log In</strong></a></li> With the <li><a href="<?php echo SITE_URL ?>/index.php/downloads"><strong>Downloads</strong></a></li> ? Quote
Moderators mark1million Posted February 27, 2011 Moderators Report Posted February 27, 2011 Just add this at the top of that tpl, <?php if(Auth::LoggedIn() == false) { echo 'Please login to view this page.'; return; } ?> You can also hide in the nav bar by putting the line under the section if logged in. Quote
Alex Posted March 1, 2011 Author Report Posted March 1, 2011 is there a way to prevent access to the index page. specifically the downloads. i tried to add .zip tothe htaccess file and that worked, but then when legitimate pilots tried to d/l the got the 404 error? Quote
Moderators mark1million Posted March 1, 2011 Moderators Report Posted March 1, 2011 Hi im not quite following what you need, that code above will prevent joe bloggs from accessing the downloads. Quote
Moderators mark1million Posted March 1, 2011 Moderators Report Posted March 1, 2011 In fact looking at my site the index page of the downloads should already be protected for logged in users already. Quote
Tom Posted March 1, 2011 Report Posted March 1, 2011 Mark is right. Downloads page is, by default, only available to logged in users. Open up core/modules/Downloads/Downloads.php and check, it should look something like this: class Downloads extends CodonModule { public function index() { if(!Auth::LoggedIn()) { echo 'You must be logged in to access this page!'; return; } $this->set('allcategories', DownloadData::GetAllCategories()); $this->render('downloads_list.tpl'); } And so on. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.