diff --git a/Westdc/Authentication/AuthenticationService.php b/Westdc/Authentication/AuthenticationService.php index 9bf780e..80216aa 100644 --- a/Westdc/Authentication/AuthenticationService.php +++ b/Westdc/Authentication/AuthenticationService.php @@ -2,11 +2,9 @@ namespace Westdc\Authentication; use Zend\Permissions\Acl\Acl; -use Zend\Permissions\Acl\Role\GenericRole as Role; -use Zend\Permissions\Acl\Resource\GenericResource as Resource; use Westdc\Helpers\Assist as view; use Westdc\Member\Cookie; -use Zend\Mvc\MvcEvent; +use Westdc\User\Account; class AuthenticationService { @@ -86,7 +84,7 @@ class AuthenticationService if($mb->checkcookie()) { $account = new Account(); - $account->cookieLogin(array($mb->FieldUsername=>$mb->user,$mb->FieldPasword=>$mb->srpwd)); + $account->cookieLogin(array('username'=>$mb->user)); } } } diff --git a/Westdc/User/Account.php b/Westdc/User/Account.php index 9c526ff..d3525d6 100644 --- a/Westdc/User/Account.php +++ b/Westdc/User/Account.php @@ -60,16 +60,21 @@ class Account implements EventManagerAwareInterface } //获取账号信息,数组 - public function getAccountInfo($id = 0) - { - if($id == 0) - { - $id = view::User('id'); - } - $sql = "SELECT * FROM {$this->memberTable} WHERE id=$id"; - $rs = $this->db->query($sql); - return $rs->fetch(); - } + public function getAccountInfo($id = 0) + { + + if(is_string($id)) + $sql = "SELECT * FROM {$this->conf->table->member} WHERE username='$id'"; + elseif(is_numeric($id)) + { + if($id == 0) + $id == view::User('id'); + $sql = "SELECT * FROM {$this->conf->table->member} WHERE id=$id"; + } + + $rs = $this->db->query($sql); + return $rs->fetch(\PDO::FETCH_ASSOC); + } //注册 public function register($data) @@ -212,7 +217,14 @@ class Account implements EventManagerAwareInterface public function cookieLogin($data) { - return $this->storeLogin($data,false); + $data = $this->getAccountInfo($data['username']); + + if(!$data) + { + return false; + } + + return $this->storeLogin($data,false); } //注册信息参数