Reputation: 13948
I have successfully implemented the onUserAuthenticate
event to implement my custom authentication API inside the Joomla! site that I am working on.
Now I want to also have some custom code run on the onUserLogout
event.
I have added the following code to the custom authentication plugin file.
But this method is not getting fired/invoked while the previous one(onUserAuthenticate
) is working just fine.
/**
* Method to handle the SSO logout
*
* @param array $user Holds the user data.
* @param array $options Array holding options (client, ...).
*
* @return boolean Always returns true.
*
* @since 1.6
*/
public function onUserLogout($user, $options = array()) {
if (JFactory::getApplication()->isSite()) {
// Set the cookie to expired date.
setcookie('customAuth', '123', time() - (60 * 60 * 24 * 365), '/', '.customdomain.org');
}
return true;
}
Upvotes: 1
Views: 198
Reputation: 13948
Okay so I was getting it all wrong.
So I was adding the aforementioned method inside the same plugin file that handled the onUserAuthenticate
.
For Joomla! the login is a separate process which has its respective events like onUserAuthenticate
.
But it seems like the event onUserLogout
has to be inside the plugin with the type
of user
.
So I created a separate plugin inside the user
plugin type directory, installed it, and enabled it....And voila!! it worked.
This had me scratching my head for quite a while.
Upvotes: 1