Jump to content

Login/Logout redirection in a Module


Andudi
 Share

Recommended Posts

dear all

I try to implement another kind of login/logout redirection in a module.

I have found some concerning methodes in ProcessLogin that I try to call in the init() methode of my module:

class ProcessLoginRedirect extends ProcessLogin                         
{
    public static function getModuleInfo()
    {
        return array(
            'title' => 'Login Redirect',     
            'version' => 1,
            'summary' => 'Define constant redirect page for login and logout process.',
            'autoload' => true 
        );
    }

    public function init()
    {
        parent::init(); // required

        $this->setLoginURL('/');
        $this->setLogoutURL('/');
    }
}

for testing, I try to redirect to the homepages frontend ('/'), but this does not work at all... I suppose, that this code is not called at all...

what do I wrong? what could I do for debugging?

thanks for help

Link to comment
Share on other sites

thank you for your answer LostKobrakai

my idea was too simple tough... but yes, now I got it: the process field in the edit page of /admin/login... setting to my new class (ProcessLoginRedirect) overwrites the one of the core module (ProcessLogin)...

... and it works fine now... but only for the admin user!

If I login as normal user I get the following Error in the header:

       TemplateFile: You don't have permission

any good idea wher I should digg?

thanks in advance.

Andreas

Link to comment
Share on other sites

hm, seems not to be that simple... and I think to extend ProcessLogin and call the setLoginURL method is not the right way to do it...

Next I tried to hook the ___execute() method of ProcessLogin and call setLoginURL there... works but then I have no information about the user and I failed to create a filter.

Now my solution is to hook ___loginSuccess($user) of the Session class... now I have access to the user and can use $session->redirect depending of the users settings (defined with an additional field at the user page).

For me this topic can be closed. But I think since I found a bunch of forum questions about that (since I do not want to rewrite the login page, they do not really help me) that it could be explained somewhere how this is meant by the devs.

thank you for your great work, since PW is much more intuitive than any other CMS I tried!

Andreas

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...