5 changed files with 49 additions and 2 deletions
@ -0,0 +1,13 @@ |
|||
<?php |
|||
|
|||
namespace app\event; |
|||
|
|||
class AgentPasswordChange |
|||
{ |
|||
public $aid; |
|||
|
|||
public function __construct($aid) |
|||
{ |
|||
$this->aid = $aid; |
|||
} |
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
<?php |
|||
|
|||
namespace app\listener; |
|||
|
|||
use app\event\AgentPasswordChange; |
|||
use think\facade\Cache; |
|||
|
|||
class LogoutAgent |
|||
{ |
|||
/** |
|||
* 监听用户登陆状态 |
|||
* @param AgentPasswordChange $event |
|||
* @throws \Psr\SimpleCache\InvalidArgumentException |
|||
*/ |
|||
public function handle(AgentPasswordChange $event) |
|||
{ |
|||
$aid = $event->aid; |
|||
|
|||
$agentData = Cache::store('redis')->get('login_agent_user_data'); |
|||
if ($agentData) { |
|||
$agentData = unserialize($agentData); |
|||
if ($agentData['id'] == $aid) { |
|||
Cache::store('redis')->delete('login_agent_user_data'); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue