|
|
|
@ -5,20 +5,22 @@ import cn.estsh.i3plus.core.api.iservice.busi.ICoreTreeService;
|
|
|
|
|
import cn.estsh.i3plus.core.api.iservice.busi.ISysUserService;
|
|
|
|
|
import cn.estsh.i3plus.core.apiservice.controller.DemoAuthController;
|
|
|
|
|
import cn.estsh.i3plus.core.apiservice.serviceimpl.busi.SysLocaleLanguageService;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.util.CommonConstWords;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil;
|
|
|
|
|
import cn.estsh.i3plus.pojo.platform.bean.SessionUser;
|
|
|
|
|
import cn.estsh.i3plus.pojo.platform.bean.SysLocaleLanguage;
|
|
|
|
|
import cn.estsh.i3plus.pojo.platform.bean.SysMenu;
|
|
|
|
|
import cn.estsh.impp.framework.base.controller.BaseController;
|
|
|
|
|
import cn.estsh.impp.framework.base.controller.CoreBaseController;
|
|
|
|
|
import cn.estsh.impp.framework.boot.auth.AuthUtil;
|
|
|
|
|
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
|
|
|
|
|
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
|
|
|
|
|
import cn.estsh.impp.framework.boot.exception.ImppExceptionEnum;
|
|
|
|
|
import cn.estsh.impp.framework.boot.util.ResultBean;
|
|
|
|
|
import cn.estsh.impp.framework.boot.util.ValidatorBean;
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
import org.apache.shiro.authc.AuthenticationException;
|
|
|
|
|
import org.apache.shiro.authc.*;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
@ -58,6 +60,7 @@ public class AuthController extends CoreBaseController {
|
|
|
|
|
@ApiOperation(value="登陆",notes="登陆")
|
|
|
|
|
public ResultBean login(HttpServletRequest request, String loginName, String loginPwd, String languageCode){
|
|
|
|
|
LOGGER.info("用户登陆 loginName:{} loginPwd:{} languageCode:{}",loginName,loginPwd,languageCode);
|
|
|
|
|
ResultBean result = null;
|
|
|
|
|
try {
|
|
|
|
|
ValidatorBean.checkNotNull(loginName,"用户名不能为空");
|
|
|
|
|
ValidatorBean.checkNotNull(loginPwd,"密码不能为空");
|
|
|
|
@ -65,27 +68,38 @@ public class AuthController extends CoreBaseController {
|
|
|
|
|
|
|
|
|
|
SessionUser user = userService.queryUserLogin(loginName,loginPwd,languageCode);
|
|
|
|
|
|
|
|
|
|
String redisKey = CommonConstWords.USER_LOGIN_ERROR + "_" + user.getUser().getId();
|
|
|
|
|
redisCore.deleteKey(redisKey);
|
|
|
|
|
|
|
|
|
|
LOGGER.info("会员登陆:{}",user);
|
|
|
|
|
AuthUtil.setSessionObject("languageCode",languageCode);
|
|
|
|
|
ResultBean result = new ResultBean(true, "", AuthUtil.getSessionUser());
|
|
|
|
|
result = new ResultBean(true, "", AuthUtil.getSessionUser());
|
|
|
|
|
result.setUrl("/");
|
|
|
|
|
return result;
|
|
|
|
|
} catch (IncorrectCredentialsException e) {
|
|
|
|
|
// 密码错误
|
|
|
|
|
systemLoginService.doLoginPasswordError(loginName);
|
|
|
|
|
result = ResultBean.fail(ImppExceptionEnum.LOGIN_EXCEPTION_USER_PASSWORD);
|
|
|
|
|
result.setErrorMsg("密码输入错误。如果输错次数超过" + CommonConstWords.USER_LOGIN_ERROR_MAX_NUM + "次,用户将被锁定。");
|
|
|
|
|
} catch (CredentialsException e) {
|
|
|
|
|
// 用户名或密码错误
|
|
|
|
|
result = ResultBean.fail(ImppExceptionEnum.LOGIN_EXCEPTION_USER_NAME);
|
|
|
|
|
} catch (LockedAccountException e) {
|
|
|
|
|
// 账号已锁定
|
|
|
|
|
result = ResultBean.fail(ImppExceptionEnum.LOGIN_EXCEPTION_USER_LOCKING);
|
|
|
|
|
} catch (UnknownAccountException e) {
|
|
|
|
|
// 用户信息不存在
|
|
|
|
|
result = ResultBean.fail(ImppExceptionEnum.LOGIN_EXCEPTION_USER_INFO_NULL);
|
|
|
|
|
} catch (AuthenticationException e) {
|
|
|
|
|
ResultBean result = ResultBean.fail();
|
|
|
|
|
Throwable cause = e.getCause();
|
|
|
|
|
if(cause instanceof ImppBusiException ){
|
|
|
|
|
ImppBusiException exception = (ImppBusiException) cause;
|
|
|
|
|
result.setErrorMsg(exception.getMessage() + exception.getErrorSolution());
|
|
|
|
|
}else {
|
|
|
|
|
// 系统异常
|
|
|
|
|
result = ResultBean.fail(e.getMessage()).setCode(ImppExceptionEnum.SYSTEM_EXCEPTION.getCode());
|
|
|
|
|
result.setErrorMsg(e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
} catch (ImppBusiException e) {
|
|
|
|
|
return ResultBean.fail(e);
|
|
|
|
|
result = ResultBean.fail(e);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
return ResultBean.fail(e.getMessage()).setCode(ImppExceptionEnum.SYSTEM_EXCEPTION.getCode());
|
|
|
|
|
result = ResultBean.fail(e.getMessage()).setCode(ImppExceptionEnum.SYSTEM_EXCEPTION.getCode())
|
|
|
|
|
.setErrorMsg(ImppExceptionEnum.SYSTEM_EXCEPTION.getDescription());
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|