Login to Yii application from another application (phpBB)

Hello,

I am integration Yii application with phpBB forum. I have created an auth for my custom login so that I can log users to Yii application with they login to forum. I have implemented the login functionality in Yii application as well. Can some one guide me how do I login users from phpBB to Yii application. These two application are on same domain.

Thanks

You should have a UserIdentity class in your project:


/**

 * UserIdentity represents the data needed to identity a user.

 * It contains the authentication method that checks if the provided

 * data can identity the user.

 */

class UserIdentity extends CUserIdentity

{

	const ERROR_CONFIRMREGISTRATION=4;

	

	private $_id;

	/**

 	* Authenticates a user.

 	* @return boolean whether authentication succeeds.

 	*/

	public function authenticate($md5=true)

	{

    	$user=User::model()->find('LOWER(username)=?',array(strtolower($this->username)));

    	if($user===null)

        	$this->errorCode=self::ERROR_USERNAME_INVALID;

    	else if((($md5)?md5($this->password):$this->password)!==$user->password)

        	$this->errorCode=self::ERROR_PASSWORD_INVALID;

    	else if($user->confirmRegistration)

        	$this->errorCode=self::ERROR_CONFIRMREGISTRATION;

    	else

    	{

        	$this->_id=$user->id;

        	$this->username=$user->username;

        	$this->errorCode=self::ERROR_NONE;

    	}

    	return !$this->errorCode;

	}



Do what you need to do in the ‘authenticate’ function. :)

Thank for the reply jacmoe :)

Are your suggesting that in another application (phpBB) I can do some thing like

$identity = new UserIdentity ();

$identity->username = "test";

$identity->password = "test";

$identity->authenticate();

and this will login the user to my Yii application as well?

You want to integrate external application in your Yii project.

You need to check out the cookies and Session values that are set when user logged in PHPBB.

then you should use your code.