Jump to content

Joomla Authentication Plugin | WHMCS


Redundant

Recommended Posts

I suggest you just install the module from the firs post, then just edit modules/mod_whmcs/mod_whmcs.php. You have to edit it anyway and it's easy.

 

Here's mine:

 

<?php
//Client Login//
/**
* WHMCS Client Login Module
* @package Joomla
* @copyright Copyright (C) 2008 Kurt Nelson. All rights reserved.
* @license [url]http://www.gnu.org/copyleft/gpl.html[/url] GNU/GPL, see LICENSE.php
*/
?>
<form method="post" action="https://www.sonoracomm.com/client/dologin.php?goto=clientarea">
Email Address: <input type="text" name="username" size="20" /><br>
Password: <input type="password" name="password" size="20" /><br>
<input type="submit" value="Login">
</form>

 

Make sure you post to your own server...

 

IHTH,

 

G

Link to comment
Share on other sites

  • Replies 57
  • Created
  • Last Reply

Top Posters In This Topic

I've installed both versions of these plugins for joomla on a 1.58 install and neither one of them appears as a valid plugin when you try to create a module for login.

 

The plugins are active and configured in the Plugin manager however if I try to create a new module neither appear as an available module type... only the default joomla "mod_login" is available?

 

Any suggestions?

 

I really need to get this working!

Link to comment
Share on other sites

It is an authentication plugin which really doesn't have anything to do with a Module. The plugin simply authenticates against WHMCS database of users instead of Joomla. Although, you can still use Joomla User Database as an authentication database too: When configuring the WHMCS Joomla Auth plugin, there is an "ORDER" to place authentication plugins into.

 

So, once you have that setup, the Default Joomla Login module would work fine. Where you would want a custom Login Module is perhaps to bypass Joomla Auth/Login all together and have the login FORM post the credentials to the WHMCS dologin.php (thus, bypassing Joomla Authentication completely).

 

If all you want is to authenticate against your WHMCS database of users, without redirecting over to WHMCS, then the Joomla Auth Plugin will help in this respect. The user would remain in Joomla and be logged in having been authenticated against the WHMCS Database. If they navigate over to a WHMCS area, they would need to login again (its not a bridge for sessions).

 

For logging directly into WHMCS, you would create a simple form (module), that posts to the WHMCS dologin.php which bypasses all Joomla Login/Authentication.

 

Hope this clears that up...?

Link to comment
Share on other sites

the one thing that I'd like to change is the email as username in joomla. this really mucks up a bunch of Joomla specific components.

 

For example commenting software, fireboard, etc. all show the users email address as username.

 

Do you know how this can be changed to reflect the "first name, lastname" from whmcs instead of the email?

Link to comment
Share on other sites

I've got both versions of the plugin working thanks for everyones help....

 

However on some machines, with both ie and ff there is a warning across the top of the broswer when logging in or logging out.

 

Warning: cannot modify header information - headers already send by ( link to authentication plugin.php:0) on line 0

 

What does this mean and how do I remove it? Any ideas?

Link to comment
Share on other sites

The only warning that come up are when either of the whmcs authentication plugins enabled in Joomla. the other note from the mambo thread stated:

 

"if you use include or require in your page. don't use similar header in current page and included page. This is important header must be top of the codes. Don't use headers bottom of html codes."

 

Is this the case in either of the authentication plugins? I'm not a coder so I wouldn't know what to look for!

Link to comment
Share on other sites

I tested the very top joomla module and I think it didn't solve a major problem of "Login through of site" Client need to login again when they go to client area.

 

My joomla module also didn't a solution for integrate joomla and WHMCS may be we need to wait "Matt" or other WHMCS's programmer looking for this request.

Link to comment
Share on other sites

  • 1 month later...

It would be awesome if you could post your results.

If your feeling real active you could write a wiki page.

Or feel free to email me a quick "what you did" with some screen shots and ill add it to the wiki for you. PM me if you interested

Link to comment
Share on other sites

I tested the module posted in this topic but it's not really what I want.

 

It gives the ability to login into Joomla with the login/password from WHMCS but don't create a session for WHMCS, so the user have to login twice. Maybe it's possible to add this feature but I don't know how.

 

Now I will test the JFusion one.

Link to comment
Share on other sites

  • 2 weeks later...
you can't use jfusion... it reads the db correctly BUT you can't access the users password from the whmcs db unless you use the whmcs API.

 

Last time I checked jfusion had no facility for making api calls while access the db

 

That's good to know - so the other direction then:

 

How do we make a WHMCS session?

Link to comment
Share on other sites

I have confirmed that the front-end has a Cookie named: PHPSESSID that authenticates the session.

 

The WHMCSUID & SHMCSPW are for the "remember me" option and are not required to authorize the session. We may however, be able to write those 2 cookies using the API to handle the auto-login from joomla!

Link to comment
Share on other sites

This is a Joomla! plugin for using the WHMCS database for authenticating users - it DOES NOT authenticate WHMCS users against the Joomla! database

Upload to: joomla/plugins/authentication/whmcsauth.php

    <?php defined('_JEXEC') or die();
   jimport('joomla.event.plugin');
   /**
   * External WHMCS Database Authentication Plugin.  Based on the example in Joomla! Core
   *
   * @package    Bridger.Joomla
   * @subpackage Plugins
   * @license    GNU/GPL
   */
   class plgAuthenticationWhmcsauth extends JPlugin
   {
      /**
       * Constructor
       *
       * For php4 compatability we must not use the __constructor as a constructor for plugins
       * because func_get_args ( void ) returns a copy of all passed arguments NOT references.
       * This causes problems with cross-referencing necessary for the observer design pattern.
       *
       * @param   object   $subject   The object to observe
       * @param   array   $config      An array that holds the plugin configuration
       * @since   1.5
       */

      function plgAuthenticationWhmcsauth(& $subject, $config){
         parent::__construct($subject, $config);

      }
      /**
       * This method should handle any authentication and report back to the subject
       *
       * @access   public
       * @param   array   $credentials   Array holding the user credentials
       * @param   array   $options      Array of extra options
       * @param   object   $response      Authentication response object
       * @return   boolean
       * @since   1.5
       */

      function onAuthenticate( $credentials, $options, &$response )
      {
         /*
         * Here you would do whatever you need for an authentication routine with the credentials
         *
         * In this example the mixed variable $return would be set to false
         * if the authentication routine fails or an integer userid of the authenticated
         * user if the routine passes
         */
         $plugin =&JPluginHelper::getPlugin('authentication','whmcsauth');
         $params = new JParameter( $plugin->params );

         $url          = $params->get('whmcsapi');         // URL to WHMCS API File
         $wusername       = $params->get('whmcsadminuser');   // WHMCS Admin username
         $wpassword       = $params->get('whmcsadminpass');   // WHMCS Admin password


         // WHMCS API Call
         $postfields["username"] = $wusername;
         $postfields["password"] = md5($wpassword);
         $postfields["action"] = "getclientsdatabyemail";
         $postfields["email"] = $credentials["username"];

         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, $url);
         curl_setopt($ch, CURLOPT_POST, 1);
         curl_setopt($ch, CURLOPT_TIMEOUT, 100);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
         $data = curl_exec($ch);
         curl_close($ch);

         $data = explode(";",$data);
         foreach ($data AS $temp) {
           $temp = explode("=",$temp);
           $results[$temp[0]] = $temp[1];
         }
         if ($results["result"]=="success") {
           # Record Retrieved OK
            if ($credentials["password"] == $results["password"]) {

                $uid = $results['userid']; //store whmcs user ID to be used later to pull the password hash from the WHMCS DB
               mysql_connect (<WHMCS DATABASE HOST>,<WHMCS DB USERNAME>,"<WHMCS DB UN PASSWORD>"); ##connect to WHMCS database
               mysql_select_db ('<WHMCS DATABASE NAME>'); # select whmcs database
               $query = sprintf("SELECT `password` FROM `tblclients` WHERE tblclients.id =%s", #select passsword field from WHMCS DB
                 mysql_real_escape_string($uid));
               $result = mysql_query($query);
                     while ($row = mysql_fetch_assoc($result)) {
                     $whmcspw = $row['password'];
                     }
                     mysql_close();

               $days = 5;
               $time=time()+60*60*24*$days;
               $whmcspw2 = urldecode($whmcspw);
               setrawcookie("WHMCSPW",$whmcspw, $time,"/");
               setcookie("WHMCSUID",$uid, $time,"/");
               $response = JUser::getInstance(); // Bring the user in line with the rest of the system
               $response->fullname =  $results["firstname"]." ".$results["lastname"];
               $response->email = $results["email"];
               $response->status = JAUTHENTICATE_STATUS_SUCCESS;            
               return true;
            }else{
               $response->status = JAUTHENTICATE_STATUS_FAILURE;
               $response->error_message = 'Invalid User Name or Password';
               return false;         
            }

         } else {
           # An error occured
           echo "The following error occured: ".$results["message"];
            $response->status = JAUTHENTICATE_STATUS_FAILURE;
            $response->error_message = 'Invalid User Name or Password';
            return false;   
         }

   }


   }

   ?> 

 

Upload to: joomla/plugins/authentication/whmcsauth.xml

<?xml version="1.0" encoding="utf-8"?>
<install version="1.5" type="plugin" group="authentication">
   <name>Authentication - WHMCS</name>
<author>Marc Bridger</author>
<creationDate>October 2008</creationDate>
<copyright>(C) 2005 - 2007 Open Source Matters. All rights reserved.</copyright>
<license>http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL</license>
<authorEmail>pixelbrite@gmail.com</authorEmail>
<authorUrl>pixelbrite@gmail.com</authorUrl>
<version>1.5</version>
   <description>WHMCS Authentication Plugin.  Modified version of Joomla! Core Authentication Plugin. </description>
   <files>
       <filename plugin="whmcsauth">whmcsauth.php</filename>
   </files>
   <params>
	<param name="whmcsapi" type="text" size="20" default="" label="WHMCS API URL" description="URL for the API.PHP file. eg (http://www.yourdomain.com/whmcs/includes/api.php)" />
	<param name="whmcsadminuser" type="text" size="20" default="" label="WHMCS Admin Username" description="WHMCS Administrator Username" />
	<param name="whmcsadminpass" type="password" size="20" default="" label="WHMCS Admin Password" description="WHMCS Administrator Password" />		
   </params>
</install>

KNOWN LIMITATIONS:

  • Logout of Joomla will NOT logout WHMCS
  • You will get locked out of the Joomla ADMIN if you only enable this auth plugin!
  • You may get PHP warning messages about not being able to set the cookies because the headers have already been sent

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated