Commit e47fbdb9 authored by hujun's avatar hujun

修改登录

parent 4c19fb6b
......@@ -3,6 +3,7 @@
namespace app\index\controller;
use app\index\extend\Basic;
use app\model\AdminModel;
use app\model\Agents;
use app\model\AuthRule;
use think\Session;
......@@ -24,6 +25,7 @@ class Login extends Basic
parent::__construct($request);
$this->loginAgent=new Agents();
$this->authRule=new AuthRule();
$this->loginDb = new AdminModel();
}
public function login()
......@@ -40,8 +42,32 @@ class Login extends Basic
*/
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);
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");
/*$name = $this->request->param("username");
$password = $this->request->param("passwd");
if (!isset($name) || !isset($password)) {
......@@ -126,7 +152,7 @@ class Login extends Basic
return $this->response('200', '登录成功', $data);
}else {
$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