Commit a35e60bd authored by clone's avatar clone

Merge branch 'test'

parents 23424e73 e47fbdb9
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace app\index\controller; namespace app\index\controller;
use app\index\extend\Basic; use app\index\extend\Basic;
use app\model\AdminModel;
use app\model\Agents; use app\model\Agents;
use app\model\AuthRule; use app\model\AuthRule;
use think\Session; use think\Session;
...@@ -24,6 +25,7 @@ class Login extends Basic ...@@ -24,6 +25,7 @@ class Login extends Basic
parent::__construct($request); parent::__construct($request);
$this->loginAgent=new Agents(); $this->loginAgent=new Agents();
$this->authRule=new AuthRule(); $this->authRule=new AuthRule();
$this->loginDb = new AdminModel();
} }
public function login() public function login()
...@@ -40,8 +42,32 @@ class Login extends Basic ...@@ -40,8 +42,32 @@ class Login extends Basic
*/ */
public function loginVerify() public function loginVerify()
{ {
$name = $_POST["username"];
$passwd = $_POST["passwd"];
if (!isset($name) || !isset($passwd)) {
return view("/login/login", [ "msg" => "用户名或密码不能为空" ]);
}
$params["name"] = $name;
$params["pswd"] = md5($passwd);
$result = $this->loginDb->verifyUser($params);
$name = $this->request->param("username"); if (count($result) > 0) {
//todo 更新登录信息
$this->loginDb->updateLoginTime($result[0]["id"]);
Session::set("userName",$result[0]["name"]);
Session::set("userId",$result[0]["id"]);
Session::set("lastLoginTime",time());
$this->operating_records($result[0]["id"],1,'后台登陆'); //记录操作日志
// $this->redirect('/admin.php/index/banner');
// return view("/admin.php/index/banner", [ "msg" => "用户名或密码错误" ]);
return $this->response('200', '登录成功');
} else {
// return view("/login/login", [ "msg" => "用户名或密码错误" ]);
return $this->response('101', '用户名或密码错误');
}
/*$name = $this->request->param("username");
$password = $this->request->param("passwd"); $password = $this->request->param("passwd");
if (!isset($name) || !isset($password)) { if (!isset($name) || !isset($password)) {
...@@ -126,7 +152,7 @@ class Login extends Basic ...@@ -126,7 +152,7 @@ class Login extends Basic
return $this->response('200', '登录成功', $data); return $this->response('200', '登录成功', $data);
}else { }else {
$this->redirect('/admin.php/'.$url); $this->redirect('/admin.php/'.$url);
} }*/
// } // }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment