change login triggers in login function,add session write function in Auth service
This commit is contained in:
parent
cb9e731792
commit
68f53c9d9a
|
@ -7,6 +7,7 @@ use Zend\Authentication\Storage\Session as SessionStorage;
|
||||||
class Auth
|
class Auth
|
||||||
{
|
{
|
||||||
public $auth;
|
public $auth;
|
||||||
|
|
||||||
function __construct($getAuthService = false)
|
function __construct($getAuthService = false)
|
||||||
{
|
{
|
||||||
$config = Config::get();
|
$config = Config::get();
|
||||||
|
@ -25,11 +26,23 @@ class Auth
|
||||||
return $this->auth->clearIdentity();
|
return $this->auth->clearIdentity();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getIdentity($field)
|
public function getIdentity($field = "")
|
||||||
{
|
{
|
||||||
|
if(empty($field))
|
||||||
|
return $this->auth->getIdentity();
|
||||||
|
|
||||||
if(isset($this->auth->getIdentity()->$field))
|
if(isset($this->auth->getIdentity()->$field))
|
||||||
return $this->auth->getIdentity()->$field;
|
return $this->auth->getIdentity()->$field;
|
||||||
else
|
else
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function write($user)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(is_array($user))
|
||||||
|
$user = (object)$user;
|
||||||
|
|
||||||
|
$this->auth->getStorage()->write($user);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -130,7 +130,7 @@ class Account extends AbstractEventManager implements ServiceManagerAwareInterfa
|
||||||
//登陆
|
//登陆
|
||||||
public function login($data)
|
public function login($data)
|
||||||
{
|
{
|
||||||
$results = $this->getEventManager()->trigger('login.checkParam', $this, compact('data'));
|
$results = $this->getEventManager()->trigger('login.pre', $this, compact('data'));
|
||||||
$cache_data = $results->last();
|
$cache_data = $results->last();
|
||||||
|
|
||||||
if($cache_data !== true)
|
if($cache_data !== true)
|
||||||
|
|
Loading…
Reference in New Issue