From 5a0ccd3944133423c20b94d855945999def22495 Mon Sep 17 00:00:00 2001 From: Li Jianxuan Date: Thu, 8 Jan 2015 05:44:14 +0000 Subject: [PATCH] fixed login bug --- vendor/Sookon/User/Account.php | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/vendor/Sookon/User/Account.php b/vendor/Sookon/User/Account.php index 018a7f80..4600b3b6 100644 --- a/vendor/Sookon/User/Account.php +++ b/vendor/Sookon/User/Account.php @@ -54,13 +54,18 @@ class Account implements EventManagerAwareInterface //获取账号信息,数组 public function getAccountInfo($id = 0) { - if($id == 0) - { - $id = view::User('id'); - } - $sql = "SELECT * FROM {$this->conf->table->member} WHERE id=$id"; + + 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(); + return $rs->fetch(\PDO::FETCH_ASSOC); } //注册 @@ -158,7 +163,7 @@ class Account implements EventManagerAwareInterface $auth = new AuthenticationService(); $auth->setStorage(new SessionStorage($this->config->session_namespace)); - + $email = $user->email; $results = $this->getEventManager()->trigger('login.success.createAvatar', $this, compact('email')); $user->avatar = $results->last(); @@ -167,13 +172,19 @@ class Account implements EventManagerAwareInterface $id = $user->id; $results = $this->getEventManager()->trigger('login.success.updateStatus', $this, compact('id')); - var_dump($user); - exit(); return array('success'=>1); } public function cookieLogin($data) { + + $data = $this->getAccountInfo($data['username']); + + if(!$data) + { + return false; + } + return $this->storeLogin($data,false); }