From 637f3890d39fbef9a75a99d8b6b318b568676f16 Mon Sep 17 00:00:00 2001 From: wanghongjun <1445693971@qq,com> Date: Thu, 30 Nov 2023 17:49:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=AE=A1=E7=90=86=E5=91=98?= =?UTF-8?q?=E5=AF=86=E7=A0=81=E5=90=8E=E5=87=BA=E5=8F=91=E9=80=80=E5=87=BA?= =?UTF-8?q?=E7=99=BB=E9=99=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/AdminUser.php | 5 +++++ app/event.php | 3 +++ app/event/AdminPasswordChange.php | 13 +++++++++++++ app/listener/LogoutAdmin.php | 28 ++++++++++++++++++++++++++++ 4 files changed, 49 insertions(+) create mode 100644 app/event/AdminPasswordChange.php create mode 100644 app/listener/LogoutAdmin.php diff --git a/app/controller/AdminUser.php b/app/controller/AdminUser.php index ce9d6e3..eb6ee30 100644 --- a/app/controller/AdminUser.php +++ b/app/controller/AdminUser.php @@ -4,11 +4,13 @@ declare (strict_types = 1); namespace app\controller; use app\BaseController; +use app\event\AdminPasswordChange; use app\middleware\CheckAdmin; use app\model\RebateRecords; use think\exception\ValidateException; use think\facade\Cache; use think\facade\Db; +use think\facade\Event; use think\facade\Filesystem; use think\facade\Request; use app\model\AdminUser as AdminModel; @@ -70,6 +72,9 @@ class AdminUser extends BaseController $user = $AdminModel->modifyPassword($data,$adminData['id']); if ($user['status']) { + + $event = new AdminPasswordChange($adminData['id']); + Event::trigger(AdminPasswordChange::class,$event); return $this->renderSuccess('修改成功'); } else { return $this->renderError($user['msg']); diff --git a/app/event.php b/app/event.php index b2354e5..09f48ab 100644 --- a/app/event.php +++ b/app/event.php @@ -16,6 +16,9 @@ return [ 'app\event\AgentPasswordChange' => [ 'app\listener\LogoutAgent', ], + 'app\event\AdminPasswordChange' => [ + 'app\listener\LogoutAdmin', + ], ], 'subscribe' => [ diff --git a/app/event/AdminPasswordChange.php b/app/event/AdminPasswordChange.php new file mode 100644 index 0000000..35a2943 --- /dev/null +++ b/app/event/AdminPasswordChange.php @@ -0,0 +1,13 @@ +aid = $aid; + } +} \ No newline at end of file diff --git a/app/listener/LogoutAdmin.php b/app/listener/LogoutAdmin.php new file mode 100644 index 0000000..8b56aea --- /dev/null +++ b/app/listener/LogoutAdmin.php @@ -0,0 +1,28 @@ +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'); + } + } + } +} \ No newline at end of file