2016-05-27 9 views
0

私はjoomlaのユーザー、パスワードを認証するAPIを持っている。 Joomla 2.5では完全に動作していますが、Joomla 3.5ではApplication Instantiationエラーが発生しています。コードの一部は以下の通りである:Joomla JAuthenticationアプリケーションインスタンス化エラー

関数checkAuthentication($ユーザ名、$パスワード) {

jimport('joomla.user.authentication'); 
$auth = & JAuthentication::getInstance(); 
$credentials = array('username' => $username, 'password' => $password); 
$options = array(); 
$response = $auth->authenticate($credentials, $options); 

if ($response->status != JAUTHENTICATE_STATUS_SUCCESS) 
{ 
    echo "Failure"; 
} 
else 
{ 
    echo "Success~" . $username; 
} 

}

それはライン$ AUTH = & JAuthentication ::のgetInstanceに失敗しています();

設定ファイルのdb設定などのすべての設定を確認しました。誰かが理由を知るのを助けてくれますか?

答えて

1

以下のコードは、Joomla認証プラグイン(plugins/authentication/joomla/joomla.php)の修正版です。

$query = $db->getQuery(true); 
$query->select(array('id, 'password')); 
$query->from('#__users'); 
$query->where($db->quoteName('username') . ' = ' . $db->quote($username)); 
$db->setQuery($query); 
$result = $db->loadObject(); 

/* 
* This block supports Joomla 3.2 upwards 
*/ 
if ($result) 
{ 
    $match = JUserHelper::verifyPassword($password, $result->password, $result->id); 

    if ($match === true) 
    { 
     $user = JUser::getInstance($result->id); 
     $response->email = $user->email; 
     $response->fullname = $user->name; 

     if (JFactory::getApplication()->isAdmin()) 
     { 
      $response->language = $user->getParam('admin_language'); 
     } 
     else 
     { 
      $response->language = $user->getParam('language'); 
     } 

     $response->status = JAuthentication::STATUS_SUCCESS; 
     $response->error_message = ''; 
    } 
    else 
    { 
     // Invalid password 
     $response->status = JAuthentication::STATUS_FAILURE; 
     $response->error_message = JText::_('JGLOBAL_AUTH_INVALID_PASS'); 
    } 
} 
+0

ありがとうSean!それは完璧に働いています。 –

関連する問題