From c93d05a1a3ef2f21c90423e57bbd72a309285538 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=8D=8E=E6=B8=85?= <18691022700@163.com> Date: Sat, 17 Jan 2026 23:12:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=81=E7=A6=81=20token=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/api/model/UserToken.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/application/api/model/UserToken.php b/application/api/model/UserToken.php index 628dce50..6603540a 100644 --- a/application/api/model/UserToken.php +++ b/application/api/model/UserToken.php @@ -82,6 +82,16 @@ class UserToken extends Model return ['code' => 0, 'msg'=> 'token更新失败']; } }else{ + //查询有多少个信息 + $user_token = db::name('user_token')->where('user_id', $user_id)->select(); + if(count($user_token) > 1){ + //删除多余的token + foreach ($user_token as $key => $value) { + if($value['id'] != $data_token['id']){ + $this->where('id', $value['id'])->delete(); + } + } + } if(!($this->where('user_id', $user_id)->update(['token' => $tokenString, 'expiretime' => $expiretime]))){ return ['code' => 0, 'msg'=> 'token更新失败']; }