Commit 81ed586d authored by hujun's avatar hujun

全局验证用户状态

parent 9f4a31e1
......@@ -163,7 +163,7 @@ class Basic extends Controller
echo json_encode(array( "code" => "300", "msg" => "AuthToken不能为空!", "data" => [], "type" => "json" ));
exit;
}
//$this->verifyAgentInfo();
$this->verifyAgentInfo();
$this->verifyTime();
}
......@@ -186,11 +186,28 @@ class Basic extends Controller
public function verifyAgentInfo()
{
$agentModel = new AAgents();
$params["status"] = 0;
$params["id"] = $this->agentId;
$agentArr = $agentModel->getAgentById("id,store_id,name,phone", $params);
if (count($agentArr) > 0 && ($agentArr["id"] != $this->agentId)) {
echo json_encode(array( "code" => "300", "msg" => "用户验证失败,重新登录!", "data" => [], "type" => "json" ));
$agent_status = $agentModel->getAgentsById($this->agentId, 'status');
if ($agent_status != 0) {
switch ($agent_status) {
case 1 :
$msg = '您目前是长假状态,请联系人事进行更改';
break;
case 2 :
$msg = '您目前是已离职状态,请联系人事进行更改。';
break;
case 3 :
$msg = '您已转勤,请重登录。';
break;
case 4 :
$msg = '该账号已被列入黑名单!';
break;
case 5 :
$msg = '该账号已被冻结!';
break;
default :
$msg = '帐号异常';
}
echo json_encode(array( "code" => "300", "msg" => $msg, "data" => [], "type" => "json" ));
exit;
}
return true;
......
......@@ -138,6 +138,7 @@ class Basic extends Controller
if (!in_array($requestPath, $this->filterVerify)) {
$this->userVerify();
$this->userAuth($requestPath);
$this->verifyAgentInfo($this->userId);
}
//获取默认城市
......@@ -463,4 +464,44 @@ class Basic extends Controller
exit;
}
}
/**
* @return bool
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function verifyAgentInfo()
{
$agentModel = new AAgents();
$agent_status = $agentModel->getAgentsById($this->userId, 'status');
if ($agent_status != 0) {
switch ($agent_status) {
case 1 :
$msg = '您目前是长假状态,请联系人事进行更改';
break;
case 2 :
$msg = '您目前是已离职状态,请联系人事进行更改。';
break;
case 3 :
$msg = '您已转勤,请重登录。';
break;
case 4 :
$msg = '该账号已被列入黑名单!';
break;
case 5 :
$msg = '该账号已被冻结!';
break;
default :
$msg = '帐号异常';
}
if ($this->request->isAjax()) {
echo json_encode(array( "code" => "300", "msg" => $msg, "data" => [], "type" => "json" ));exit;
} else {
$this->success($msg, '/index/login');
}
}
return true;
}
}
\ No newline at end of file
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