1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- <?php
- namespace app\admin\controller;
- use app\BaseController;
- use app\common\model\mysql\AdminUser;
- use think\facade\View;
- class Login extends BaseController
- {
- public function index()
- {
- return View::fetch();
- }
- public function md5()
- {
- echo md5('admin_singwa_abc');
- }
- public function check()
- {
- if (!$this->request->isPost()) {
- return show(config('status.error'), '请求方式错误');
- }
-
- $username = $this->request->param('username', '', 'trim');
- $password = $this->request->param('password', '', 'trim');
- $captcha = $this->request->param('captcha', '', 'trim');
- if (empty($username) || empty($password) || empty($captcha)) {
- return show(config('status.error'), '参数不能为空');
- }
-
- if (!captcha_check($captcha)) {
-
- return show(config('status.error'), '验证码不正确');
- }
- $adminUserObj = new AdminUser();
- $adminUser = $adminUserObj->getAdminUserByUsername($username);
- if (empty($adminUser) || $adminUser->status != config('status.mysql.table_normal')) {
- return show(config('status.error'), '不存在该用户');
- }
- $adminUser = $adminUser->toArray();
- if ($adminUser['password'] !== md5($password . '_singwa_abc')) {
- return show(config('status.error'), '密码错误');
- }
- return show(config('status.success'), '登陆成功');
- }
- }
|