change user login function

This commit is contained in:
Jianxuan Li 2015-01-16 23:37:40 +08:00
parent a5e8eb8c06
commit cb9e731792
2 changed files with 13 additions and 34 deletions

View File

@ -10,12 +10,10 @@ use Zend\Authentication\Adapter\DbTable;
use Westdc\Helpers\Assist as view; use Westdc\Helpers\Assist as view;
use Westdc\Helpers\Config; use Westdc\Helpers\Config;
use Westdc\Helpers\Dbh as dbh; use Westdc\Helpers\Dbh as dbh;
use Westdc\Db\Pdo as Db;
use Westdc\Db\Db as Zend_Db; use Westdc\Db\Db as Zend_Db;
use Westdc\Mail\Mail; use Westdc\Mail\Mail;
use Westdc\User\Member; use Westdc\User\Member;
class Account extends AbstractEventManager implements ServiceManagerAwareInterface class Account extends AbstractEventManager implements ServiceManagerAwareInterface
{ {
public $memberTable = "tbl_member"; public $memberTable = "tbl_member";
@ -149,8 +147,10 @@ class Account extends AbstractEventManager implements ServiceManagerAwareInterfa
if(isset($state['success'])) if(isset($state['success']))
{ {
//$mb = new Member(); $user = (array)$state['user'];
//$mb->putcookie($data[$this->FieldUsername],md5($data[$this->FieldPasword])); $this->getEventManager()->trigger('login.success', $this, compact('user'));
}else{
$this->getEventManager()->trigger('login.failed', $this, compact('data'));
} }
return $state; return $state;
@ -185,22 +185,18 @@ class Account extends AbstractEventManager implements ServiceManagerAwareInterfa
$result = $authAdapter->authenticate(); $result = $authAdapter->authenticate();
$user = $authAdapter->getResultRowObject(null,array('password'));
if(!$result->isValid()) if(!$result->isValid())
{ {
return array("error"=>"用户信息验证失败"); return array("error"=>"用户信息验证失败");
} }
$email = $user->email; $user = $authAdapter->getResultRowObject(null,array('password'));
$results = $this->getEventManager()->trigger('login.success.createAvatar', $this, compact('email'));
$user->avatar = $results->last();
$auth->getStorage()->write($user); $auth->getStorage()->write($user);
$id = $user->id; return array(
$results = $this->getEventManager()->trigger('login.success.updateStatus', $this, compact('id')); 'success'=>1,
'user' => $user
return array('success'=>1); );
} }
public function cookieLogin($data) public function cookieLogin($data)

View File

@ -1,17 +0,0 @@
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2014/11/4
* Time: 11:23
*/
namespace Westdc\Service\ServiceAgent;
use Westdc\Member\Account as Westdc_Account;
class Account extends Westdc_Account{
}