$app = JApplicationCms::getInstance();
$credentials = array(
'username'=>$username
'password'=>$password
);
$options = array('action'=>'core.login.site'); // Define options and suppress 'cannot access private section of this website' warning in Joomla Core
$app->login($credentials,$options);
The user is logged in with no error messages or the call fails and returns false or throws an exception
Joomla displays an error message: "Call to a member function get() on null" from the line "$app->login($credentials,$options);"
Attempting to use JApplication (via JFactory::getApplication()) instead of JApplicationCms results in the same error. JApplicationWeb, which is indicated as a replacement for JApplicationCms in the Joomla 3.6 API documentation simply does not have a login method. Attempting to use triggerEvent instead seems to do nothing, but I'll admit I've never used it before and could have done it incorrectly. I tried the following:
$app = JApplicationWeb::getInstance();
$credentials = array(
'username'=>$username
'password'=>$password
);
$app->triggerEvent('core.login.site',$credentials)
PHP Built On Linux jbdev01 3.10.0-514.6.1.el7.x86_64 #1 SMP Wed Jan 18 13:06:36 UTC 2017 x86_64
Database Version 5.5.52-MariaDB
Database Collation utf8_general_ci
Database Connection Collation utf8mb4_general_ci
PHP Version 7.0.16
Web Server Apache/2.4.6 (CentOS) OpenSSL/1.0.1e-fips mod_fcgid/2.3.9 PHP/7.0.16
WebServer to PHP Interface apache2handler
The Joomla install was freshly updated from 3.6.5 to 3.7.0 with nothing else changed. The code worked perfectly well before the update.
I'm not really familiar with how Joomla authentication works beyond what I researched for our plugin-turned-component, so I'm afraid I don't know how to pursue this without dedicating significant research time to it (which I don't have, given my other projects).
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2017-05-02 18:43:05 |
Closed_By | ⇒ | joomla-cms-bot |
Priority | Urgent | ⇒ | Medium |
Closed_By | joomla-cms-bot | ⇒ | franz-wohlkoenig |
Set to "closed" on behalf of @franz-wohlkoenig by The JTracker Application at issues.joomla.org/joomla-cms/15663
closed as no Core Issue.
Aah. Thanks for the help then, and my apologies for wasting time. That shouldn't have taken me long to find.
Sounds like you are looking for support rather than reporting an issue in Joomla.
The 'correct' way to attempt authentication with the Joomla API in recent versions of Joomla would be something like:
A full example, based on the /index.php file of Joomla can be seen here (prepared for you)
https://gist.github.com/PhilETaylor/9bdf7b3032825f9f457e86196bb3909d
As this is not an issue in Joomla please close this issue and seek support in the Joomla Forums