From cb9e731792340560a5924b738a90c9f2a8c07e79 Mon Sep 17 00:00:00 2001 From: Jianxuan Li Date: Fri, 16 Jan 2015 23:37:40 +0800 Subject: [PATCH] change user login function --- Westdc/Member/Account.php | 30 +++++++++++-------------- Westdc/Service/ServiceAgent/Account.php | 17 -------------- 2 files changed, 13 insertions(+), 34 deletions(-) delete mode 100644 Westdc/Service/ServiceAgent/Account.php diff --git a/Westdc/Member/Account.php b/Westdc/Member/Account.php index 43da9fe..b4b2335 100644 --- a/Westdc/Member/Account.php +++ b/Westdc/Member/Account.php @@ -10,12 +10,10 @@ use Zend\Authentication\Adapter\DbTable; use Westdc\Helpers\Assist as view; use Westdc\Helpers\Config; use Westdc\Helpers\Dbh as dbh; -use Westdc\Db\Pdo as Db; use Westdc\Db\Db as Zend_Db; use Westdc\Mail\Mail; use Westdc\User\Member; - class Account extends AbstractEventManager implements ServiceManagerAwareInterface { public $memberTable = "tbl_member"; @@ -149,9 +147,11 @@ class Account extends AbstractEventManager implements ServiceManagerAwareInterfa if(isset($state['success'])) { - //$mb = new Member(); - //$mb->putcookie($data[$this->FieldUsername],md5($data[$this->FieldPasword])); - } + $user = (array)$state['user']; + $this->getEventManager()->trigger('login.success', $this, compact('user')); + }else{ + $this->getEventManager()->trigger('login.failed', $this, compact('data')); + } return $state; }//login @@ -184,23 +184,19 @@ class Account extends AbstractEventManager implements ServiceManagerAwareInterfa ; $result = $authAdapter->authenticate(); - - $user = $authAdapter->getResultRowObject(null,array('password')); - + if(!$result->isValid()) { return array("error"=>"用户信息验证失败"); } - - $email = $user->email; - $results = $this->getEventManager()->trigger('login.success.createAvatar', $this, compact('email')); - $user->avatar = $results->last(); - $auth->getStorage()->write($user); - - $id = $user->id; - $results = $this->getEventManager()->trigger('login.success.updateStatus', $this, compact('id')); + + $user = $authAdapter->getResultRowObject(null,array('password')); + $auth->getStorage()->write($user); - return array('success'=>1); + return array( + 'success'=>1, + 'user' => $user + ); } public function cookieLogin($data) diff --git a/Westdc/Service/ServiceAgent/Account.php b/Westdc/Service/ServiceAgent/Account.php deleted file mode 100644 index b35cee4..0000000 --- a/Westdc/Service/ServiceAgent/Account.php +++ /dev/null @@ -1,17 +0,0 @@ -