You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

57 lines
1.9 KiB

package com.eco.plugin.xx.hlzjsso.controller;
import com.eco.plugin.xx.hlzjsso.config.PluginSimpleConfig;
import com.eco.plugin.xx.hlzjsso.utils.IPWhiteUtils;
import com.eco.plugin.xx.hlzjsso.utils.ResponseUtils;
import com.eco.plugin.xx.hlzjsso.utils.Utils;
import com.fr.decision.webservice.annotation.LoginStatusChecker;
import com.fr.json.JSONObject;
import com.fr.third.springframework.stereotype.Controller;
import com.fr.third.springframework.web.bind.annotation.PostMapping;
import com.fr.third.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@Controller
@LoginStatusChecker(required = false)
public class ControllerSelf {
@PostMapping(value = "/canLogin")
@ResponseBody
public void canLogin(HttpServletRequest req,HttpServletResponse res){
JSONObject param = Utils.getRequestBody(req);
String username = param.getString("username");
PluginSimpleConfig psc = PluginSimpleConfig.getInstance();
boolean isWhite = IPWhiteUtils.inWhite(req,psc.getWhite());
if(isWhite || !psc.getIsAll()){
ResponseUtils.successResponse(res,"");
return ;
}
boolean isAdmin = false;
try {
isAdmin = Utils.isAdmin(username);
} catch (Exception e) {
ResponseUtils.failedResponse(res,"判断管理员失败!");
return ;
}
//管理员且管理员权限控制开启
if(isAdmin && psc.getIsAdmin()){
ResponseUtils.failedResponse(res,"外网环境管理员禁止登陆!");
return ;
}
//普通用户权限开始
if(!isAdmin && psc.getIsPt()){
ResponseUtils.failedResponse(res,"外网环境普通账户禁止登陆!");
return ;
}
ResponseUtils.successResponse(res,"");
}
}