diff --git a/components/WebUser.php b/components/WebUser.php index 4a664f6..04c4095 100644 --- a/components/WebUser.php +++ b/components/WebUser.php @@ -48,16 +48,19 @@ protected function afterLogin($fromCookie) public function updateSession() { $user = Yii::app()->getModule('user')->user($this->id); - $this->name = $user->username; - $userAttributes = CMap::mergeArray(array( - 'email'=>$user->email, - 'username'=>$user->username, - 'create_at'=>$user->create_at, - 'lastvisit_at'=>$user->lastvisit_at, - ),$user->profile->getAttributes()); - foreach ($userAttributes as $attrName=>$attrValue) { - $this->setState($attrName,$attrValue); + if ($user!==false){ + $this->name = $user->username; + $userAttributes = CMap::mergeArray(array( + 'email'=>$user->email, + 'username'=>$user->username, + 'create_at'=>$user->create_at, + 'lastvisit_at'=>$user->lastvisit_at, + ),$user->profile->getAttributes()); + foreach ($userAttributes as $attrName=>$attrValue) { + $this->setState($attrName,$attrValue); + } } + } public function model($id=0) {