修改使用登录及添加用户在线验证

This commit is contained in:
巴掌 committed 2018-10-17 13:46:49 +08:00
1 parent 1b4abd1ee3
commit 2cb2202ed2
9 files changed
+68 -76

No files matched your search

+31 -15
View File
@@ -38,7 +38,7 @@ class Index extends Controller
$result = $validate->check($data);
$msg = $validate->getError();
if(!$result){
$this->redirect('/notfound',['msg' => $msg]);
$this->error($msg);
}
// 重新计算密码
@@ -46,18 +46,12 @@ class Index extends Controller
$data['password'] = $md5->hash($miyao,$data['password']);
// 验证用户名和密码
$userid = $membermod->check($data);
$userid = $this->check($data['username'],$data['password']);
if($userid)
{
// 获取用户信息
$userinfo = $membermod->get($userid);
// Session存值
session('username', $userinfo->username);
session('password', $userinfo->password);
session('userid', $userinfo->id);
// 设置cookie值
if( request()->post('online') == true )
{
// 设置
@@ -66,6 +60,7 @@ class Index extends Controller
}
// 将本次信息上传到服务器上
$userinfo = $membermod->get($userid);
$userinfo->lastip = $userinfo->ip;
$userinfo->ip = request()->host();
$userinfo->denglucishu = ['inc', 1];
@@ -75,19 +70,40 @@ class Index extends Controller
// 跳转到首页
$this->redirect(url('/'));
return '验证完成';
//模版
}else{
// 跳转到首页
$this->redirect(url('/notfound',['msg' => '用户名或密码错误']));
return '验证失败';
// 提示错误信息
$this->error('用户名或密码错误');
}
return '';
}
// 已知密码进行验证
public function check($username,$password)
{
//实例化类
$membermod = new membermod();
//验证密码
$yz = $membermod->check($username,$password);
if($yz)
{
// Session存值
session('username', $username);
session('password', $password);
session('userid', $yz);
}else{
// 清除cookie
cookie(null, 'think_');
// 清除session(当前作用域)
session(null);
}
return $yz;
}
// 首次登录添加admin
public function first()