From 70f4202ae691c63381b56602dee1a72414cabb15 Mon Sep 17 00:00:00 2001 From: Li Jianxuan Date: Tue, 22 Apr 2014 09:52:59 +0000 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=99=BB=E5=BD=95=E6=97=B6?= =?UTF-8?q?=E7=9A=84=E9=80=BB=E8=BE=91=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vendor/Sookon/User/Account.php | 15 ++++++--------- vendor/Sookon/User/Handle/LoginHandle.php | 21 ++++++++++++++------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/vendor/Sookon/User/Account.php b/vendor/Sookon/User/Account.php index f8a58bca..fa274efa 100644 --- a/vendor/Sookon/User/Account.php +++ b/vendor/Sookon/User/Account.php @@ -136,9 +136,9 @@ class Account implements EventManagerAwareInterface if(isset($cache_data['error']) && !empty($cache_data['error'])) { - return array('error'=>$cache_data); + return array('error'=>$cache_data['error']); } - + $state = $this->storeLogin($cache_data); if(isset($state['success'])) @@ -156,17 +156,14 @@ class Account implements EventManagerAwareInterface $auth = new AuthenticationService(); $auth->setStorage(new SessionStorage($this->config->session_namespace)); - unset($data[$this->conf->field->pwd]); + $user = (object)$data; - $email = $data['email']; + $email = $user->email; $results = $this->getEventManager()->trigger('login.success.createAvatar', $this, compact('email')); - $data['avatar'] = $results->last(); - - $user = json_decode(json_encode($data));; - + $user->avatar = $results->last(); $auth->getStorage()->write($user); - $id = $data['id']; + $id = $user->id; $results = $this->getEventManager()->trigger('login.success.updateStatus', $this, compact('id')); return array('success'=>1); diff --git a/vendor/Sookon/User/Handle/LoginHandle.php b/vendor/Sookon/User/Handle/LoginHandle.php index 0f29892e..e3d43ab3 100644 --- a/vendor/Sookon/User/Handle/LoginHandle.php +++ b/vendor/Sookon/User/Handle/LoginHandle.php @@ -23,9 +23,10 @@ class LoginHandle implements \Sookon\User\Event\LoginEvent $this->db = new Db(); $this->conf = Config::get(); + $config = Config::get('sync'); $this->dsn = array( - array('host'=>'localhost','db'=>'','user'=>'','pwd'=>''), - array('host'=>'localhost','db'=>'','user'=>'','pwd'=>''), + array('host'=>$config->qinghaihu->hostname,'db'=>$config->qinghaihu->database,'user'=>$config->qinghaihu->username,'pwd'=>$config->qinghaihu->password), + //array('host'=>'localhost','db'=>'','user'=>'','pwd'=>''), ); } @@ -76,7 +77,7 @@ class LoginHandle implements \Sookon\User\Event\LoginEvent $uname_avalible = false; - if( isset($row['error']) && !empty($row['error']) ) + if( isset($row['error']) || !empty($row['error']) ) { if(count($this->dsn) > 0) { @@ -93,14 +94,20 @@ class LoginHandle implements \Sookon\User\Event\LoginEvent } } } + }else{ + $uname_avalible = true; } - if(!$uname_avalible) + if($uname_avalible == false) + { return $row; - else + }else if($uname_avalible == true){ $this->last_login_data = $row; + return $this->checkPwd($row,$password); + }else{ + return array("error"=>'用户名密码错误'); + } - return $this->checkPwd($row,$password); } //获取数据 @@ -111,7 +118,7 @@ class LoginHandle implements \Sookon\User\Event\LoginEvent if(empty($memberTable)) $memberTable = $this->conf->table->member; - $sql = "SELECT id,{$this->conf->field->pwd} FROM $memberTable WHERE {$this->conf->field->uname}=?"; + $sql = "SELECT * FROM $memberTable WHERE {$this->conf->field->uname}=?"; $sth = $db->prepare($sql); $rs = $sth->execute(array($username)); $row = $sth->fetch();