Joomla authentication plugin WebService cannot check my ID? - Joomla! Forum - community, help and support


my joomla site need invoke other web site users login, administrator provides webservice file me call.

i use google authentication plugin modifications:

code: select all

<?php
include("nusoap.php");
defined('_jexec') or die;


class plgauthenticationwsdl extends jplugin
{
   /**
    * method should handle authentication , report subject
    *
    * @param   array   $credentials  array holding user credentials
    * @param   array   $options      array of options
    * @param   object  &$response    authentication response object
    *
    * @return  boolean
    *
    * @since   1.5
    */
   public function onuserauthenticate($credentials, $options, &$response)
   {
      // load plugin language
      $this->loadlanguage();

      // no backend authentication
      if (jfactory::getapplication()->isadmin() && !$this->params->get('backendlogin', 0))
      {
         return;
      }
      
      
      
      $success = 0;
      
      $username = $credentials['username'];
      $userpass = $credentials['password'];
      
      
      try{
         $client = new soapclient('http://mydemo/services/simple?wsdl');
         $arypara = array('login'=>"$username", 'password'=>"$userpass");
         $resultstr = $client->call("commonsimpleauth",$arypara);   
            
         if ($resultstr){
            
            $email = $credentials['username'] . '@mydemo.com';

         // security checks existing local accounts
         $db = jfactory::getdbo();

         $localusernamechecks = array(strstr($email, '@', true), $email);

         $query = $db->getquery(true)
            ->select('id, activation, username, email, block')
            ->from('#__users')
            ->where('username in(' . implode(',', array_map(array($db, 'quote'), $localusernamechecks)) . ')'
               . ' or email = ' . $db->quote($email)
            );

         $db->setquery($query);

         if ($localusers = $db->loadobjectlist())
         {
            foreach ($localusers $localuser)
            {
               // local user exists same username different email address
               if ($email != $localuser->email)
               {
                  $response->status        = jauthentication::status_failure;
                  $response->error_message = jtext::sprintf('jglobal_auth_failed', jtext::_('plg_gmail_error_local_username_conflict'));

                  return;
               }
               else
               {
                  // existing user disabled locally
                  if ($localuser->block || !empty($localuser->activation))
                  {
                     $response->status        = jauthentication::status_failure;
                     $response->error_message = jtext::_('jglobal_auth_access_denied');

                     return;
                  }

                  // keep local username existing accounts
                  $credentials['username'] = $localuser->username;

                  break;
               }
            }
         }
         elseif (jfactory::getapplication()->isadmin())
         // wont' allow backend access without local account
         {
            $response->status        = jauthentication::status_failure;
            $response->error_message = jtext::_('jerror_login_denied');

            return;
         }

         $response->status        = jauthentication::status_success;
         $response->error_message = '';
         $response->email         = $email;

         // reset username ended using
         $response->username = $credentials['username'];
         $response->fullname = $credentials['username'];
         
         
      }
      else{  $response->status        = jauthentication::status_failure;
         $response->error_message = jtext::sprintf('jglobal_auth_failed', $message);}

         
   }
catch(soapfault $e){
         
      }      
      

      
   }
}


the above code external user authentication plugin, whatever input username or password can log on, background creates corresponding user.
the judge whether error?


code: select all

$username = $credentials['username'];
$userpass = $credentials['password'];
      
      
      try{
         $client = new soapclient('http://mydemo/services/simple?wsdl');
         $arypara = array('login'=>"$username", 'password'=>"$userpass");
         $resultstr = $client->call("commonsimpleauth",$arypara);   
            
         if ($resultstr){
            
            $email = $credentials['username'] . '@mydemo.com';



here part of contents of wsdl file

code: select all

<wsdl:message name="mainrequest">
<wsdl:part name="args" type="impl:arrayof_soapenc_string"/>
</wsdl:message>
<wsdl:message name="mainresponse"></wsdl:message>
<wsdl:message name="commonsimpleauthrequest">
<wsdl:part name="login" type="soapenc:string"/>
<wsdl:part name="password" type="soapenc:string"/>
</wsdl:message>
<wsdl:message name="commonsimpleauthresponse">
<wsdl:part name="commonsimpleauthreturn" type="soapenc:string"/>
</wsdl:message>
<wsdl:porttype name="simpleauthws">
<wsdl:operation name="main" parameterorder="args">
<wsdl:input message="impl:mainrequest" name="mainrequest"/>
<wsdl:output message="impl:mainresponse" name="mainresponse"/>
</wsdl:operation>
<wsdl:operation name="commonsimpleauth" parameterorder="login password">
<wsdl:input message="impl:commonsimpleauthrequest" name="commonsimpleauthrequest"/>
<wsdl:output message="impl:commonsimpleauthresponse" name="commonsimpleauthresponse"/>
</wsdl:operation>
</wsdl:porttype>






Comments

Popular posts from this blog

Joomla 3.3 Installation Error message - Joomla! Forum - community, help and support

Multilanguage infinite redirect loop error. - Joomla! Forum - community, help and support

trim media limit reached