|
@@ -20,7 +20,7 @@ class Auth extends BaseController {
|
|
|
public function login() {
|
|
|
|
|
|
if ($user = session("user")) {
|
|
|
- if($user['usertype'] == 2){
|
|
|
+ if ($user['usertype'] == 2) {
|
|
|
return redirect("/enterprise");
|
|
|
}
|
|
|
}
|
|
@@ -29,23 +29,26 @@ class Auth extends BaseController {
|
|
|
$username = $this->request["username"];
|
|
|
$pwd = $this->request["password"];
|
|
|
$usertype = $this->request["usertype"];
|
|
|
+ $captcha = $this->request["captcha"];
|
|
|
$user = new UserApi($username, $pwd, $usertype);
|
|
|
if (!$userinfo = $user->getUserInfo()) {
|
|
|
$msg = "用户不存在";
|
|
|
} else if (!$user->checkPwd()) {
|
|
|
$login_fail = session('login_fail');
|
|
|
- if($login_fail){
|
|
|
+ if ($login_fail) {
|
|
|
$login_fail++;
|
|
|
- if($login_fail >= 5){
|
|
|
- session('captcha',1);
|
|
|
+ if ($login_fail >= 5) {
|
|
|
+ session('isCaptcha', 1);
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
$login_fail = 1;
|
|
|
}
|
|
|
- session('login_fail',$login_fail);
|
|
|
+ session('login_fail', $login_fail);
|
|
|
$msg = "用户名或者密码错误";
|
|
|
- } else if($res_msg = $user->checkState()){
|
|
|
- if($user->info['checkState'] == 2){
|
|
|
+ } else if (session("isCaptcha") == 1 && !captcha_check($captcha)) {
|
|
|
+ $msg = "验证码错误";
|
|
|
+ } else if ($res_msg = $user->checkState()) {
|
|
|
+ if ($user->info['checkState'] == 2) {
|
|
|
return redirect("/common/auth/enterprise_edit");
|
|
|
}
|
|
|
$msg = $res_msg;
|
|
@@ -82,7 +85,6 @@ class Auth extends BaseController {
|
|
|
return redirect("/index/auth/login");
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 验证密码
|
|
|
*/
|
|
@@ -102,29 +104,29 @@ class Auth extends BaseController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public function policy(){
|
|
|
+ public function policy() {
|
|
|
|
|
|
|
|
|
return view("", []);
|
|
|
}
|
|
|
|
|
|
- public function policy_list(){
|
|
|
+ public function policy_list() {
|
|
|
$level = $this->request->post('level');
|
|
|
- if($level){
|
|
|
- $where[] = ['level','=',$level];
|
|
|
- }else{
|
|
|
- $where[] = ['level','>',0];
|
|
|
+ if ($level) {
|
|
|
+ $where[] = ['level', '=', $level];
|
|
|
+ } else {
|
|
|
+ $where[] = ['level', '>', 0];
|
|
|
}
|
|
|
$list = Db::table('new_policy')->where($where)->select()->toArray();
|
|
|
$result = [];
|
|
|
- foreach ($list as $k => $v){
|
|
|
+ foreach ($list as $k => $v) {
|
|
|
$check = [];
|
|
|
$condition = [];
|
|
|
- if(!empty($v['checks'])){
|
|
|
- $check = explode(',',$v['checks']);
|
|
|
+ if (!empty($v['checks'])) {
|
|
|
+ $check = explode(',', $v['checks']);
|
|
|
}
|
|
|
- if(!empty($v['condition'])){
|
|
|
- $condition = explode(',',$v['condition']);
|
|
|
+ if (!empty($v['condition'])) {
|
|
|
+ $condition = explode(',', $v['condition']);
|
|
|
}
|
|
|
$item = [
|
|
|
'id' => $v['id'],
|
|
@@ -133,25 +135,24 @@ class Auth extends BaseController {
|
|
|
'checks' => $check,
|
|
|
'condition' => $condition
|
|
|
];
|
|
|
- array_push($result,$item);
|
|
|
+ array_push($result, $item);
|
|
|
}
|
|
|
return json($result);
|
|
|
}
|
|
|
|
|
|
- public function policy_update(){
|
|
|
+ public function policy_update() {
|
|
|
$res = $this->request->post();
|
|
|
- foreach ($res as $k => $v){
|
|
|
+ foreach ($res as $k => $v) {
|
|
|
|
|
|
$update = [];
|
|
|
|
|
|
- if(count($v['condition']) > 0){
|
|
|
+ if (count($v['condition']) > 0) {
|
|
|
$update['condition'] = json_encode($v['condition']);
|
|
|
}
|
|
|
- if(count($update) > 0){
|
|
|
- Db::table('new_policy')->where('id',$v['id'])->save($update);
|
|
|
+ if (count($update) > 0) {
|
|
|
+ Db::table('new_policy')->where('id', $v['id'])->save($update);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
}
|