合并用户登录界面
This commit is contained in:
1 parent
53615988c8
commit
fd7a567f1c
27 files changed
+256
-778
No files matched your search
+111
-37
@@ -53,15 +53,15 @@ class Index
|
||||
|
||||
switch ($list['category']) {
|
||||
case 'admin':
|
||||
$data = $this->admin($list);
|
||||
$data = $this->admin($list['username'], $list['password']);
|
||||
break;
|
||||
|
||||
case 'teacher':
|
||||
$data = $this->teacher($list);
|
||||
$data = $this->teacher($list['username'], $list['password']);
|
||||
break;
|
||||
|
||||
case 'student':
|
||||
$data = $this->student($list);
|
||||
$data = $this->student($list['username'], $list['password']);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -74,33 +74,32 @@ class Index
|
||||
|
||||
|
||||
|
||||
// 登录验证
|
||||
public function admin($list)
|
||||
// 管理员登录验证
|
||||
public function admin($username, $password)
|
||||
{
|
||||
session(null);
|
||||
// 获取服务器密码
|
||||
$userinfo = AD::where('username', $list['username'])
|
||||
->where('val', 1)
|
||||
$userinfo = AD::where('username', $username)
|
||||
->where('status', 1)
|
||||
->field('id, lastip, username, ip, denglucishu, lasttime, thistime, password')
|
||||
->find();
|
||||
|
||||
if($userinfo == null)
|
||||
{
|
||||
// 清除session(当前作用域)
|
||||
session(null);
|
||||
// 验证结果;
|
||||
$data = ['msg' => '管理员帐号不存在或被禁用', 'val' => 0];
|
||||
return json($data);
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
// 验证用户名和密码
|
||||
$check = $this->check($list['password'], $userinfo->password);
|
||||
$check = $this->check($password, $userinfo->password);
|
||||
|
||||
if($check['val'] === 1)
|
||||
if($check === true)
|
||||
{
|
||||
session(null);
|
||||
session('onlineCategory', 'admin');
|
||||
session('user_id', $userinfo->id);
|
||||
session('username', $username);
|
||||
session('password', $password);
|
||||
|
||||
// 将本次信息上传到服务器上
|
||||
$userinfo->lastip = $userinfo->ip;
|
||||
@@ -111,42 +110,117 @@ class Index
|
||||
$userinfo->save();
|
||||
|
||||
// 跳转到首页
|
||||
$data = ['msg' => '验证成功', 'val' => 1];
|
||||
$data = ['msg' => '验证成功', 'val' => 1, 'url' =>'\\'];
|
||||
}else{
|
||||
// 提示错误信息
|
||||
$data = ['msg' => $check['msg'], 'val' => 0];
|
||||
$data = ['msg' => '用户名或密码错误', 'val' => 0];
|
||||
}
|
||||
|
||||
return json($data);
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
// 管理员登录验证
|
||||
public function teacher($username, $password)
|
||||
{
|
||||
session(null);
|
||||
// 获取服务器密码
|
||||
$tch = new \app\teacher\model\Teacher;
|
||||
$userinfo = $tch::where('phone', $username)
|
||||
->where('status', 1)
|
||||
->field('id, lastip, phone, ip, denglucishu, lasttime, thistime, password')
|
||||
->find();
|
||||
|
||||
if($userinfo == null)
|
||||
{
|
||||
// 验证结果;
|
||||
$data = ['msg' => '教师帐号不存在或被禁用', 'val' => 0];
|
||||
return $data;
|
||||
}
|
||||
|
||||
// 验证用户名和密码
|
||||
$check = $this->check($password, $userinfo->password);
|
||||
|
||||
if($check === true)
|
||||
{
|
||||
session('onlineCategory', 'teacher');
|
||||
session('user_id', $userinfo->id);
|
||||
session('username', $username);
|
||||
session('password', $password);
|
||||
|
||||
// 将本次信息上传到服务器上
|
||||
$userinfo->lastip = $userinfo->ip;
|
||||
$userinfo->ip = request()->ip();
|
||||
$userinfo->denglucishu = ['inc', 1];
|
||||
$userinfo->lasttime = $userinfo->getData('thistime');
|
||||
$userinfo->thistime = time();
|
||||
$userinfo->save();
|
||||
|
||||
// 跳转到首页
|
||||
$data = ['msg' => '验证成功', 'val' => 1, 'url' => '/teacherSearchChengji/index/index'];
|
||||
}else{
|
||||
// 提示错误信息
|
||||
$data = ['msg' => '用户名或密码错误', 'val' => 0];
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
// 管理员登录验证
|
||||
public function student($username, $password)
|
||||
{
|
||||
session(null);
|
||||
// 获取服务器密码
|
||||
$stu = new \app\student\model\Student;
|
||||
$userinfo = $stu::where('shenfenzhenghao', $username)
|
||||
->where('status', 1)
|
||||
->field('id, lastip, shenfenzhenghao, ip, denglucishu, lasttime, thistime, password')
|
||||
->find();
|
||||
|
||||
if($userinfo == null)
|
||||
{
|
||||
// 验证结果;
|
||||
$data = ['msg' => '教师帐号不存在或被禁用', 'val' => 0];
|
||||
return $data;
|
||||
}
|
||||
|
||||
// 验证用户名和密码
|
||||
$check = $this->check($password, $userinfo->password);
|
||||
|
||||
if($check === true)
|
||||
{
|
||||
session('onlineCategory', 'student');
|
||||
session('user_id', $userinfo->id);
|
||||
session('username', $username);
|
||||
session('password', $password);
|
||||
|
||||
// 将本次信息上传到服务器上
|
||||
$userinfo->lastip = $userinfo->ip;
|
||||
$userinfo->ip = request()->ip();
|
||||
$userinfo->denglucishu = ['inc', 1];
|
||||
$userinfo->lasttime = $userinfo->getData('thistime');
|
||||
$userinfo->thistime = time();
|
||||
$userinfo->save();
|
||||
|
||||
// 跳转到首页
|
||||
$data = ['msg' => '验证成功', 'val' => 1, 'url' => '/studentSearchChengji/index/index'];
|
||||
}else{
|
||||
// 提示错误信息
|
||||
$data = ['msg' => '用户名或密码错误', 'val' => 0];
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
// 已知密码进行验证
|
||||
public function check($srcfrom)
|
||||
public function check($inputPassword, $serverPassword)
|
||||
{
|
||||
$src = [
|
||||
'username' => ''
|
||||
,'password' => ''
|
||||
,'onlineCategory' => ''
|
||||
,'user_id' => ''
|
||||
];
|
||||
$src = array_cover($srcfrom, $src);
|
||||
|
||||
// 实例化加密类
|
||||
$md5 = new APR1_MD5();
|
||||
|
||||
//验证密码
|
||||
$check = $md5->check($inputPassword, $serverPassword);
|
||||
|
||||
if($check)
|
||||
{
|
||||
session('username', $username);
|
||||
session('password', $password);
|
||||
$data = ['msg' => '验证成功', 'val' => 1];
|
||||
}else{
|
||||
$data = ['msg' => '用户名或密码错误', 'val' => 0];
|
||||
}
|
||||
return $data;
|
||||
return $check;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user