Hello,
I write UserIdentity.php file to display User last login information. when I login I got this error "CWebUser.lastLogin is not defined". Here is my file
public function authenticate()
{
$user=User::model()->with('role')->find('LOWER(loginName)=?',array(strtolower($this->username)));
if($user===null)
{
$this->errorCode=self::ERROR_USERNAME_INVALID;
}
else if(md5($this->password)!==$user->password)
{
$this->errorCode=self::ERROR_PASSWORD_INVALID;
}
else if($user->active == 0)
$this->errorCode=self::ERROR_STATUS_NOTACTIVE;
else
{
$this->_role=$user->role->name; // save role for use in app
User::model()->updateByPk($user->id,array('lastLogin'=> date("Y-m-d H:i:s"), 'ip'=> $_SERVER['REMOTE_ADDR'] ));
$user_log= new UserLog();
$user_log->time=date("Y-m-d H:i:s");
$user_log->ip=$_SERVER['REMOTE_ADDR'];
$user_log->Event_id=$row[id];
$user_log->event=$row[name];
$user_log->detail=$row[description];
$user_log->User_id=$user->id;
$user_log->save();
$this->_id=$user->id;
[color="#FF0000"][b] $this->setState('lastLogin ', $user->lastLogin );[/b][/color]
$this->errorCode=self::ERROR_NONE;
if (!$user_log->save())
var_dump($user_log->getErrors()
);
}
return !$this->errorCode;
}