From a38a1f9e51f7141c85112585a214850010b6add4 Mon Sep 17 00:00:00 2001 From: shirne Date: Thu, 8 Aug 2024 14:34:51 +0800 Subject: [PATCH] fix --- .../index/controller/BaseController.php | 35 ++++++++++--------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/src/application/index/controller/BaseController.php b/src/application/index/controller/BaseController.php index 32343f49..d787d92c 100644 --- a/src/application/index/controller/BaseController.php +++ b/src/application/index/controller/BaseController.php @@ -254,23 +254,24 @@ private function parseDevice($userAgent) protected function checkLogin() { $this->userid = session('userid'); - - $loginsession = $this->request->cookie(SESSKEY_USER_AUTO_LOGIN); - if (!empty($loginsession)) { - cookie(SESSKEY_USER_AUTO_LOGIN, null); - $data = EncryptService::getInstance()->decrypt($loginsession); - if (!empty($data)) { - $json = json_decode($data, true); - if (!empty($json['hash'])) { - $login = MemberLoginModel::where('hash', $json['hash'])->find(); - if (!empty($login)) { - $timestamp = $json['time']; - if ($timestamp >= time()) { - $this->userid = $json['id']; - $member = MemberModel::where('id', $this->userid)->find(); - $this->setLogin($member, 0); - $this->user = $member; - $this->setAutoLogin($member, $login['id']); + if (empty($this->userid)) { + $loginsession = $this->request->cookie(SESSKEY_USER_AUTO_LOGIN); + if (!empty($loginsession)) { + cookie(SESSKEY_USER_AUTO_LOGIN, null); + $data = EncryptService::getInstance()->decrypt($loginsession); + if (!empty($data)) { + $json = json_decode($data, true); + if (!empty($json['hash'])) { + $login = MemberLoginModel::where('hash', $json['hash'])->find(); + if (!empty($login)) { + $timestamp = $json['time']; + if ($timestamp >= time()) { + $this->userid = $login['member_id']; + $member = MemberModel::where('id', $this->userid)->find(); + $this->setLogin($member, 0); + $this->user = $member; + $this->setAutoLogin($member, $login['id']); + } } } }