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