From 2107a39c322ce1188776b08a2e0bc9276154c0ff Mon Sep 17 00:00:00 2001 From: Anyon Date: Fri, 10 Feb 2017 01:00:16 -0500 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=94=A8=E6=88=B7=E7=99=BB?= =?UTF-8?q?=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controller/Index.php | 13 ++++++++ application/admin/controller/Login.php | 42 +++++++++++++++++++++++++ application/admin/controller/index.php | 0 application/admin/model/User.php | 10 ++++++ application/admin/view/index.index.html | 1 + application/admin/view/login.index.html | 1 + extend/controller/BasicAdmin.php | 19 +++++++++++ 7 files changed, 86 insertions(+) create mode 100644 application/admin/controller/Index.php create mode 100644 application/admin/controller/Login.php delete mode 100644 application/admin/controller/index.php create mode 100644 application/admin/model/User.php create mode 100644 application/admin/view/login.index.html create mode 100644 extend/controller/BasicAdmin.php diff --git a/application/admin/controller/Index.php b/application/admin/controller/Index.php new file mode 100644 index 000000000..ac657a464 --- /dev/null +++ b/application/admin/controller/Index.php @@ -0,0 +1,13 @@ + + * @date 2017/02/10 13:59 + */ +class Login extends Controller { + + /** + * 用户登录 + * @return \think\response\View + */ + public function index() { + if ($this->request->isGet()) { + return view(); + } + $username = $this->request->post('username', '', 'trim'); + $password = $this->request->post('password', '', 'trim'); + (empty($username) || strlen($username) < 4) && $this->error('登录账号长度不能少于4位有效字符!'); + (empty($password) || strlen($password) < 4) && $this->error('登录密码长度不能少于4位有效字符!'); + $user = Db::name('SystemUser')->where('username', $username)->find(); + empty($user) && $this->error('登录账号不存在,请重新输入!'); + ($user['password'] !== md5($password)) && $this->error('登录密码与账号不匹配,请重新输入!'); + session('user', $user); + $this->error('登录成功,正在进入系统...'); + } + + /** + * 退出登录 + */ + public function out() { + session('user', null); + $this->success('退出登录成功!', '@admin/login'); + } +} \ No newline at end of file diff --git a/application/admin/controller/index.php b/application/admin/controller/index.php deleted file mode 100644 index e69de29bb..000000000 diff --git a/application/admin/model/User.php b/application/admin/model/User.php new file mode 100644 index 000000000..564d87b71 --- /dev/null +++ b/application/admin/model/User.php @@ -0,0 +1,10 @@ +isLogin()) { + $this->redirect('@admin/login'); + } + } + + public function isLogin() { + return false; + } +} \ No newline at end of file