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.
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.