From cba756048169c11567eb791dad0d3e76cc94c181 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=99=AF=E7=AB=8B?= Date: Fri, 21 Jan 2022 20:22:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=99=BB=E5=BD=95=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/Login.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/admin/controller/Login.php b/app/admin/controller/Login.php index 16db22c66..7db00f557 100644 --- a/app/admin/controller/Login.php +++ b/app/admin/controller/Login.php @@ -71,8 +71,8 @@ class Login extends Controller } /*! 用户信息验证 */ $map = ['username' => $data['username'], 'is_deleted' => 0]; - $user = SystemUser::mk()->where($map)->find(); - if (empty($user)) { + $user = SystemUser::mk()->where($map)->findOrEmpty(); + if ($user->isEmpty()) { $this->app->session->set("LoginInputSessionError", true); $this->error('登录账号或密码错误,请重新输入!'); } @@ -86,9 +86,10 @@ class Login extends Controller } $this->app->session->set('user', $user->toArray()); $this->app->session->delete("LoginInputSessionError"); - $user['login_at'] = date('Y-m-d H:i:s'); - $user['login_ip'] = $this->app->request->ip(); - $user->inc('login_num')->save(); + $user->inc('login_num')->update([ + 'login_at' => date('Y-m-d H:i:s'), + 'login_ip' => $this->app->request->ip(), + ]); sysoplog('系统用户登录', '登录系统后台成功'); $this->success('登录成功', sysuri('admin/index/index')); }