findByPk($username); if($userRecord instanceof UserRecord) // if found { $user=new BlogUser($this->Manager); $user->Name=$username; // set username $user->Roles=($userRecord->role==1?'admin':'user'); // set role $user->IsGuest=false; // the user is not a guest return $user; } else return null; } /** * Checks if the specified (username, password) is valid. * This method is required by TDbUser. * @param string username * @param string password * @return boolean whether the username and password are valid. */ public function validateUser($username,$password) { // use UserRecord Active Record to look for the (username, password) pair. return UserRecord::finder()->findBy_username_AND_password($username,$password)!==null; } /** * @return boolean whether this user is an administrator. */ public function getIsAdmin() { return $this->isInRole('admin'); } } ?>