<?php
/**
-
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
{
// Need to store the user's ID:
private $_id;
public function authenticate()
{
$username=strtolower($this->username);
$user=accountEmployee::model()->find('LOWER(username)=?',array($username));
if ($user==null)// No user found!
{
$this->errorCode=self::ERROR_USERNAME_INVALID;
}
elseif (($this->password)!==$user->password)// Invalid password!
{
$this->errorCode=self::ERROR_PASSWORD_INVALID;
}
elseif($user=accountStudent::model()->find('LOWER(username)=?',array($username))
{
else if ($user==null)
$this->errorCode=self::ERROR_USERNAME_INVALID;
}
elseif (($this->password)!==$user->password)// Invalid password!
{
$this->errorCode=self::ERROR_PASSWORD_INVALID;
}
else
{
$this->_id = $user->id;
$this->username=$user->username;
$this->errorCode=self::ERROR_NONE;
}
return !$this->errorCode;
}
public function getId()
{
return $this->_id;
}
}
the above code is my example for the authentication. For a week i have been trying to figure out how to do this but unfortunately i cant debug it. I need your help guys with this problem. Advance thx.
i have a two tables for my site which are for the employee and the student accounts. i just want to know how will i connect the two tables so that yii useridentity.php can read the database on my phpmyadmin.