Authenticate on two different tables

Hi!. Does anyone know how to do separate login forms and authenticate on two different tables?

I can’t go with one table and different roles… client requested to do separate tables…

Are there tutorials ore something like that do do this?

What’s your problem with this? If you do it like in the Yii Blog Tutorial you will have a UserIdentity class like this:


class UserIdentity extends CUserIdentity {

    private $_id;

    public function authenticate() {

        $username = strtolower($this->username);

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

        if ($user === null)

            $this->errorCode = self::ERROR_USERNAME_INVALID;

        elseif (!$user->validatePassword($this->password))

            $this->errorCode = self::ERROR_PASSWORD_INVALID;

        else {

            // Validated against first table

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

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

            $this->errorCode = self::ERROR_NONE;


        return $this->errorCode == self::ERROR_NONE;


    public function getId() {

        return $this->_id;



Although this looks to me more like a design problem than a programming problem.

Is there a way to check in which table you want to look for a user? Maybe that helps, but in general I think it is more a decision of the general Model-structure for users than only for authentification.

So it would be nice if you’d describe a bit more detailed what is going on.