status = JAUTHENTICATE_STATUS_FAILURE; $response->error_message = 'Empty password not allowed'; return false; } // Initialize variables $conditions = ''; $db =& JFactory::getDBO(); //check to see if a JFusion plugin is enabled $jname = JFusionFunction::getMaster(); //if no master set then use the Joomla default if (!$jname->name) { $jname->name = 'joomla_int'; } //initialize the forum object $JFusionPlugin = JFusionFactory::getUser($jname->name); //Get the stored encrypted password $userinfo = $JFusionPlugin->getUser($credentials['username']); if ($userinfo) { //apply the cleartext password to the user object $userinfo->password_clear = $credentials['password']; $query = "SELECT name FROM #__jfusion WHERE master = 1 OR check_encryption = 1 ORDER BY master DESC"; $db->setQuery($query); $auth_models = $db->loadObjectList(); foreach($auth_models as $auth_model) { //Generate an encrypted password for comparison $model = JFusionFactory::getAuth($auth_model->name); $testcrypt = $model->generateEncryptedPassword($userinfo); if ($testcrypt == $userinfo->password){ //found a match $response->status = JAUTHENTICATE_STATUS_SUCCESS; $response->error_message = ''; return true; } } //no matching password found $response->status = JAUTHENTICATE_STATUS_FAILURE; $response->error_message = 'Invalid password'; } else { $response->status = JAUTHENTICATE_STATUS_FAILURE; $response->error_message = 'User does not exist'; } } }