Figured out a way to do a Remote Curl Login in Joomla 1.5

Your code modifications and patches you want to share with others.
Locked
eppskevin
Joomla! Apprentice
Joomla! Apprentice
Posts: 45
Joined: Thu Jul 13, 2006 11:04 pm

Figured out a way to do a Remote Curl Login in Joomla 1.5

Post by eppskevin » Tue Sep 28, 2010 5:20 pm

I keep seeing questions raised regarding this, but I never see anyone post answers. For those of you who are trying to do the following:

Login into a external web app and have that app login to your Joomla site at the same time:

First, make sure that the usernames/passwords match on both applications. I used JFusion and wrote a plugin for this component, so that I could use the UserSync feature.

Second, in components/com_user/controller.php, add this function to the file:

Code: Select all

function login_curl()
	{
		global $mainframe;
		
		$mainframe->_createSession( 'curl' );

		$options = array();
		$options['remember'] = JRequest::getBool('remember', false);
		$options['return'] = $return;

		$credentials = array();
		$credentials['username'] = JRequest::getVar('username', '', 'method', 'username');
		$credentials['password'] = JRequest::getString('passwd', '', 'post', JREQUEST_ALLOWRAW);

		//preform the login action
		$error = $mainframe->login($credentials, $options);

		$jackieURL =& JFactory::getURI();
		$jackieURL = $jackieURL->toString();
		$mainframe->redirect($jackieURL);
	}
Also, create a new com_user view called "login_curl". Just copy the "login" folder, rename it "login_curl" then change the following files:

tmpl/default_login.php:

At line 71, there's this code snippet:

Code: Select all

<input type="hidden" name="task" value="login" />
Change it to this:

Code: Select all

<input type="hidden" name="task" value="login_curl" />
view.html.php:

Change the classname to:

Code: Select all

class UserViewLogin_curl extends JView
That should be it for the Joomla hacks. Now for the external CURL call. I wrote a class that will handle this for you (attached).

This is how you use it(replace $login and $pass with the unencrypted login and password. The script will do the encrypting for you):

Code: Select all

include ("inc/CurlConnection.php");
$userinfo = new stdClass();
$userinfo->username = $login;
$userinfo->password_clear = $pass;
createSession($userinfo, '', '');
Let me know if this helps anyone!
You do not have the required permissions to view the files attached to this post.

eppskevin
Joomla! Apprentice
Joomla! Apprentice
Posts: 45
Joined: Thu Jul 13, 2006 11:04 pm

Re: Figured out a way to do a Remote Curl Login in Joomla 1.

Post by eppskevin » Tue Sep 28, 2010 6:43 pm

If you need a copy of the CurlConnection class, let me know, and I'll email it to you.

eppskevin
Joomla! Apprentice
Joomla! Apprentice
Posts: 45
Joined: Thu Jul 13, 2006 11:04 pm

Re: Figured out a way to do a Remote Curl Login in Joomla 1.

Post by eppskevin » Tue Sep 28, 2010 7:16 pm

Actually to even make this easier:

I slightly changed the class to allow you to pass in the domain of the Joomla site:

Code: Select all

include ("inc/CurlConnection.php");
$userinfo = new stdClass();
$userinfo->username = $login;
$userinfo->password_clear = $pass;
$userinfo->source_url = 'http://www.domain.com/';
createSession($userinfo, '', '');
You do not have the required permissions to view the files attached to this post.


Locked

Return to “Core Hacks and Patches”