|
@@ -59,19 +59,19 @@ import static org.jgroups.blocks.RpcDispatcher.getName;
|
|
|
@Api(value = "LoginController", description = "登录控制器")
|
|
|
@Controller
|
|
|
public class LoginController extends BaseController{
|
|
|
-
|
|
|
+
|
|
|
@Autowired
|
|
|
private SessionDAO sessionDAO;
|
|
|
-
|
|
|
+
|
|
|
@Autowired
|
|
|
private UserMapper userMapper;
|
|
|
|
|
|
@Autowired
|
|
|
private LeaderOrgNoService orgNoService;
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 管理登录
|
|
|
- * @throws IOException
|
|
|
+ * @throws IOException
|
|
|
*/
|
|
|
@ResponseBody
|
|
|
@ApiOperation(notes = "loginMobile", httpMethod = "POST", value = "用户登录")
|
|
@@ -188,7 +188,7 @@ public class LoginController extends BaseController{
|
|
|
@RequestMapping(value = "${adminPath}/login", method = RequestMethod.POST)
|
|
|
public String loginFail(HttpServletRequest request, HttpServletResponse response, Model model) {
|
|
|
Principal principal = UserUtils.getPrincipal();
|
|
|
-
|
|
|
+
|
|
|
// 如果已经登录,则跳转到管理首页
|
|
|
if(principal != null){
|
|
|
return "redirect:" + adminPath;
|
|
@@ -199,7 +199,7 @@ public class LoginController extends BaseController{
|
|
|
boolean mobile = WebUtils.isTrue(request, FormAuthenticationFilter.DEFAULT_MOBILE_PARAM);
|
|
|
String exception = (String)request.getAttribute(FormAuthenticationFilter.DEFAULT_ERROR_KEY_ATTRIBUTE_NAME);
|
|
|
String message = (String)request.getAttribute(FormAuthenticationFilter.DEFAULT_MESSAGE_PARAM);
|
|
|
-
|
|
|
+
|
|
|
if (StringUtils.isBlank(message) || StringUtils.equals(message, "null")){
|
|
|
message = "用户或密码错误, 请重试.";
|
|
|
}
|
|
@@ -209,20 +209,20 @@ public class LoginController extends BaseController{
|
|
|
model.addAttribute(FormAuthenticationFilter.DEFAULT_MOBILE_PARAM, mobile);
|
|
|
model.addAttribute(FormAuthenticationFilter.DEFAULT_ERROR_KEY_ATTRIBUTE_NAME, exception);
|
|
|
model.addAttribute(FormAuthenticationFilter.DEFAULT_MESSAGE_PARAM, message);
|
|
|
-
|
|
|
+
|
|
|
if (logger.isDebugEnabled()){
|
|
|
- logger.debug("login fail, active session size: {}, message: {}, exception: {}",
|
|
|
+ logger.debug("login fail, active session size: {}, message: {}, exception: {}",
|
|
|
sessionDAO.getActiveSessions(false).size(), message, exception);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 非授权异常,登录失败,验证码加1。
|
|
|
if (!UnauthorizedException.class.getName().equals(exception)){
|
|
|
model.addAttribute("isValidateCodeLogin", isValidateCodeLogin(username, true, false));
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 验证失败清空验证码
|
|
|
request.getSession().setAttribute(ValidateCodeServlet.VALIDATE_CODE, IdGen.uuid());
|
|
|
-
|
|
|
+
|
|
|
// 如果是手机登录,则返回JSON字符串
|
|
|
if (mobile){
|
|
|
AjaxJson j = new AjaxJson();
|
|
@@ -234,13 +234,13 @@ public class LoginController extends BaseController{
|
|
|
j.put("JSESSIONID", "");
|
|
|
return renderString(response, j.getJsonStr());
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return "modules/sys/login/sysLogin";
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 管理登录
|
|
|
- * @throws IOException
|
|
|
+ * @throws IOException
|
|
|
*/
|
|
|
@RequestMapping(value = "${adminPath}/logout", method = RequestMethod.GET)
|
|
|
public String logout(HttpServletRequest request, HttpServletResponse response, Model model) throws IOException {
|
|
@@ -248,7 +248,7 @@ public class LoginController extends BaseController{
|
|
|
// 如果已经登录,则跳转到管理首页
|
|
|
if(principal != null){
|
|
|
UserUtils.getSubject().logout();
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
// 如果是手机客户端退出跳转到login,则返回JSON字符串
|
|
|
String ajax = request.getParameter("__ajax");
|
|
@@ -269,11 +269,11 @@ public class LoginController extends BaseController{
|
|
|
Principal principal = UserUtils.getPrincipal();
|
|
|
// 登录成功后,验证码计算器清零
|
|
|
isValidateCodeLogin(principal.getLoginName(), false, true);
|
|
|
-
|
|
|
+
|
|
|
if (logger.isDebugEnabled()){
|
|
|
logger.debug("show index, active session size: {}", sessionDAO.getActiveSessions(false).size());
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 如果已登录,再次访问主页,则退出原账号。
|
|
|
if (Global.TRUE.equals(Global.getConfig("notAllowRefreshIndex"))){
|
|
|
String logined = CookieUtils.getCookie(request, "LOGINED");
|
|
@@ -284,7 +284,7 @@ public class LoginController extends BaseController{
|
|
|
return "redirect:" + adminPath + "/login";
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 如果是手机登录,则返回JSON字符串
|
|
|
if (principal.isMobileLogin()){
|
|
|
if (request.getParameter("login") != null){
|
|
@@ -295,7 +295,7 @@ public class LoginController extends BaseController{
|
|
|
}
|
|
|
return "redirect:" + adminPath + "/login";
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if(UserUtils.getMenuList().size() == 0){
|
|
|
return "modules/sys/login/noAuth";
|
|
|
}else{
|
|
@@ -325,9 +325,9 @@ public class LoginController extends BaseController{
|
|
|
|
|
|
return "modules/sys/login/sysIndex";
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
/**
|
|
|
* 切换风格
|
|
@@ -368,7 +368,7 @@ public class LoginController extends BaseController{
|
|
|
}
|
|
|
return theme;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 是否启用tab
|
|
|
*/
|
|
@@ -381,7 +381,7 @@ public class LoginController extends BaseController{
|
|
|
}
|
|
|
return "redirect:"+request.getParameter("url");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 是否是验证码登录
|
|
|
* @param useruame 用户名
|
|
@@ -409,16 +409,16 @@ public class LoginController extends BaseController{
|
|
|
}
|
|
|
return loginFailNum >= 3;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 首页
|
|
|
- * @throws IOException
|
|
|
+ * @throws IOException
|
|
|
*/
|
|
|
@RequestMapping(value = "${adminPath}/home")
|
|
|
public String home(HttpServletRequest request, HttpServletResponse response, Model model) throws IOException {
|
|
|
return "modules/iim/calendar/myCalendar";
|
|
|
//return "modules/sys/login/sysHome";
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
}
|