Help with Members Authorisation Access

Ask all your questions about the script here.
never-in-doubt
New
Posts: 14
Joined: Wed Nov 02, 2016 6:31 am

Help with Members Authorisation Access

Postby never-in-doubt » Wed Nov 02, 2016 6:42 am

Hiya

In your FAQ's under the following question:

If a visitor goes to a restricted page, how can I make that page redirect to the login form rather than output a line of code?
You would just put this line of code instead of the error code: $qls->redirect('http://www.example.com/login.php');

Can you please confirm exactly where to put the code? I have set the login and register page to redirect if they are logged in / registered but when trying to stop a guest viewing a password protected page, they only see a white page showing "You don't have the correct permissions to access this page" but I want them to redirect to the login page if they are not logged in or do not have the right permissions.

I'd like it so that if a guest visits the members page (members.php) which is hidden from guests they would be redirected to a login page (login.php), but registered members who are logged in AND who have the permissions to view that page (from within groups and masks) can view the page and content.

So brief recap - A guest visits a secure page - lets call it members.php. The info on that page is for members who have registered only. So a guest should be redirected to a login page (login.php). However if a registered member with the correct permissions tries to view the members.php page they would be able to. The only permissions / groups I have are guest (ie public), member (ie registered) and admin (ie me).

The script currently at the top of my members page is:

<?php
define('QUADODO_IN_SYSTEM', true);
require_once('includes/header.php');
$qls->Security->check_auth_page('members.php');
?>

Thanks for any help - loving the members login script.
User avatar
Douglas
Site Admin
Posts: 625
Joined: Sat Oct 27, 2007 11:29 pm
Location: BC, Canada
Contact:

Re: Help with Members Authorisation Access

Postby Douglas » Wed Nov 02, 2016 9:49 am

Inside of the check_auth_page() function in the Security.class.php file, you can make it so it redirects instead of just outputting that they don't have permission to view it. This is where the script stops:

Code: Select all

if ($this->qls->user_info['auth_' . $hash] == 0) {
      die(NO_AUTHORIZATION);
}


Replace that die(NO_AUTHORIZATION) function with something like $this->qls->redirect('http://www.example.com/login.php') and you should get the desired result.

Good luck!
never-in-doubt
New
Posts: 14
Joined: Wed Nov 02, 2016 6:31 am

Re: Help with Members Authorisation Access

Postby never-in-doubt » Wed Nov 02, 2016 1:06 pm

awesome that sorted it - thank you :)

Return to “Support”

Who is online

Users browsing this forum: No registered users and 1 guest