Search code examples
phpauthenticationjoomlacivicrm

Joomla Authentication Plugin


I've created a joomla plugin to authenticate same like normal joomla authentication, (intention is: i'm using civicrm on top of joomla, so based on civicrm membership status i want to update joomla user group for that user). Its working fine on plain joomla and Civicrm version(2.5.24).

When I tried the same plugin on my existing client site(2.5.20), its authenticating using joomla defualt authenticaiton and not using my plugin. I've installed my plugin and enabled it. but its not picking my authentication plugin.

Interestingly when I'm entering wrong user name or password its coming into my plugins "onUserAuthenticate" method. how can I get my plugin's "onUserAuthenticate" method works for all the time..

Thanks for your valuable support!!


Solution

  • I think the way Joomla authenticate user is that it use all enabled authentication plugin to authenticate your username/password.

    If you want your plugin work all the time, you can disable other plugins. So Joomla will alway fall to your onUserAuthenticate method. But note: This only work if your site does not need any other authentication plugins.

    From joomla docs

    In order for successful authentication to occur, only one of the plugins needs to return a JAUTHENTICATE_STATUS_SUCCESS result.

    Ref: https://docs.joomla.org/J3.x:Creating_an_Authentication_Plugin_for_Joomla#Wrapping_it_All_Up_and_Using_It

    I once had a request to build a joomla site but clients only want Joomla admin login on admin site, on front-End, only api user can login. What I did is I disable all authentication plugin on Joomla and create my own plugin which will check if user is on front end or back end. I used joomla code for back-end logins and my code for front-end logins.

    It work perfectly.