From 195212addc726909106275a60c0fa3d24a02c101 Mon Sep 17 00:00:00 2001 From: augushong Date: Mon, 15 Nov 2021 17:12:44 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AE=80=E5=8C=96=E6=B5=8B=E8=AF=95=E8=B4=A6?= =?UTF-8?q?=E5=8F=B7=E7=99=BB=E9=99=86=E7=9A=84=E4=BB=A3=E7=A0=81,?= =?UTF-8?q?=E6=9B=B4=E6=96=B9=E4=BE=BF=E5=88=A0=E9=99=A4;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/Login.php | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/app/admin/controller/Login.php b/app/admin/controller/Login.php index 1d7bed2..072aab9 100644 --- a/app/admin/controller/Login.php +++ b/app/admin/controller/Login.php @@ -27,35 +27,32 @@ class Login extends Common { $post_data = $this->request->post(); - + // 想要关闭测试账号,注释掉下面两行代码 + Session::set('admin_id', 1); + return json_message(); - $validate = Validate::rule('account',Rule::isRequire()) - ->rule('password',Rule::isRequire()) - ->rule('captcha',function($value){ - return \captcha_check($value)?true:'验证码错误'; - }); - if(!$validate->check($post_data)){ - Session::set('admin_id',1); - return json_message(); + $validate = Validate::rule('account', Rule::isRequire()) + ->rule('password', Rule::isRequire()) + ->rule('captcha', function ($value) { + return \captcha_check($value) ? true : '验证码错误'; + }); + + if (!$validate->check($post_data)) { return json_message($validate->getError()); } - $model_admin = Admin::where('account',$post_data['account'])->find(); + $model_admin = Admin::where('account', $post_data['account'])->find(); - if(empty($model_admin)){ - Session::set('admin_id',1); - return json_message(); + if (empty($model_admin)) { return json_message('帐号不存在'); } - if($model_admin->getData('password') !== md5($post_data['password'].$model_admin->getData('salt'))){ - Session::set('admin_id',1); - return json_message(); + if ($model_admin->getData('password') !== md5($post_data['password'] . $model_admin->getData('salt'))) { return json_message('密码错误'); } - Session::set('admin_id',$model_admin->id); + Session::set('admin_id', $model_admin->id); return json_message(); } @@ -64,6 +61,6 @@ class Login extends Common { Session::clear(); - $this->success('已经安全退出','Login/Index'); + $this->success('已经安全退出', 'Login/Index'); } }