Jump to content

Access control with login-form on the same page


lpa
 Share

Recommended Posts

I have defined a login-handler shown below to print the login-form on each page that requires access when the user is not logged in and is under some parent-page:

if ($page->parents->has('name=memberpage') { $section = 'memberpage'; }

if(!$user->isLoggedin() and $section != '') {
  # print the login form
} elseif ($user->isLoggedin() and restrict_content($section)) {
  # user doesn't belong to the required group
}

This way I can show login-form on the same page that is restricted and not redirect the user to a separate login-page. 

Now I tried to use CustomPageRoles module for simple access control. But the module redirects me to the 404-page when I don't have access, when not logged in.

How could I just check whether to print the login form or show the page with CustomPageRoles handling the access control roles? Can I somehow read with the api that the user doesn't have access to the page without redirection to 404?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...