|
@@ -13,6 +13,7 @@ import com.railway.common.exception.user.CaptchaExpireException;
|
|
|
import com.railway.common.exception.user.UserPasswordNotMatchException;
|
|
import com.railway.common.exception.user.UserPasswordNotMatchException;
|
|
|
import com.railway.common.utils.DateUtils;
|
|
import com.railway.common.utils.DateUtils;
|
|
|
import com.railway.common.utils.MessageUtils;
|
|
import com.railway.common.utils.MessageUtils;
|
|
|
|
|
+import com.railway.common.utils.SecurityUtils;
|
|
|
import com.railway.common.utils.ServletUtils;
|
|
import com.railway.common.utils.ServletUtils;
|
|
|
import com.railway.common.utils.StringUtils;
|
|
import com.railway.common.utils.StringUtils;
|
|
|
import com.railway.common.utils.ip.IpUtils;
|
|
import com.railway.common.utils.ip.IpUtils;
|
|
@@ -69,8 +70,15 @@ public class SysLoginService {
|
|
|
boolean captchaOnOff = configService.selectCaptchaOnOff();
|
|
boolean captchaOnOff = configService.selectCaptchaOnOff();
|
|
|
// 验证码开关
|
|
// 验证码开关
|
|
|
if (captchaOnOff) {
|
|
if (captchaOnOff) {
|
|
|
- validateCaptcha(username, code, uuid);
|
|
|
|
|
|
|
+ validateCaptcha(username, code, uuid);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ String initPassword = configService.selectConfigByKey("sys.user.initPassword");
|
|
|
|
|
+ password = SecurityUtils.decode(password);
|
|
|
|
|
+ if (StringUtils.isEmpty(password) || password.equals(initPassword)) {
|
|
|
|
|
+ throw new ServiceException("当前登录用密码是初始密码,请修改后重新登录!");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// 用户验证
|
|
// 用户验证
|
|
|
Authentication authentication;
|
|
Authentication authentication;
|
|
|
try {
|
|
try {
|
|
@@ -132,7 +140,7 @@ public class SysLoginService {
|
|
|
sysUser.setUserId(userId);
|
|
sysUser.setUserId(userId);
|
|
|
sysUser.setLoginIp(IpUtils.getIpAddr(ServletUtils.getRequest()));
|
|
sysUser.setLoginIp(IpUtils.getIpAddr(ServletUtils.getRequest()));
|
|
|
sysUser.setLoginDate(DateUtils.getNowDate());
|
|
sysUser.setLoginDate(DateUtils.getNowDate());
|
|
|
- if(StringUtils.isNotEmpty(mobileId)) {
|
|
|
|
|
|
|
+ if (StringUtils.isNotEmpty(mobileId)) {
|
|
|
sysUser.setMobileId(mobileId);
|
|
sysUser.setMobileId(mobileId);
|
|
|
}
|
|
}
|
|
|
userService.updateUserProfile(sysUser);
|
|
userService.updateUserProfile(sysUser);
|
|
@@ -146,19 +154,19 @@ public class SysLoginService {
|
|
|
private void updateJcebSelectedDeptId(LoginUser loginUser) {
|
|
private void updateJcebSelectedDeptId(LoginUser loginUser) {
|
|
|
SysUser user = loginUser.getUser();
|
|
SysUser user = loginUser.getUser();
|
|
|
List<SysRole> roles = user.getRoles();
|
|
List<SysRole> roles = user.getRoles();
|
|
|
- if(CollectionUtils.isNotEmpty(roles)){
|
|
|
|
|
- for(SysRole role : roles){
|
|
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(roles)) {
|
|
|
|
|
+ for (SysRole role : roles) {
|
|
|
PostTypeEnum tmpPostType = PostTypeEnum.ofRoleName(role.getRoleName());
|
|
PostTypeEnum tmpPostType = PostTypeEnum.ofRoleName(role.getRoleName());
|
|
|
- if(PostTypeEnum.CENTER == tmpPostType){
|
|
|
|
|
|
|
+ if (PostTypeEnum.CENTER == tmpPostType) {
|
|
|
// 从缓存中取本个所选车间
|
|
// 从缓存中取本个所选车间
|
|
|
Long deptId = redisCache.getCacheObject(getCacheKey(loginUser.getUserId()));
|
|
Long deptId = redisCache.getCacheObject(getCacheKey(loginUser.getUserId()));
|
|
|
- if(StringUtils.isEmpty(deptId)) {
|
|
|
|
|
|
|
+ if (StringUtils.isEmpty(deptId)) {
|
|
|
// 取默认选择的车间
|
|
// 取默认选择的车间
|
|
|
deptId = redisCache.getCacheObject(Constants.LEADER_VIEW_DEPT_INIT_KEY);
|
|
deptId = redisCache.getCacheObject(Constants.LEADER_VIEW_DEPT_INIT_KEY);
|
|
|
- if(StringUtils.isEmpty(deptId)){
|
|
|
|
|
|
|
+ if (StringUtils.isEmpty(deptId)) {
|
|
|
// 从数据库中查默认选择的车间
|
|
// 从数据库中查默认选择的车间
|
|
|
SysDept dept = deptService.selectInitDept();
|
|
SysDept dept = deptService.selectInitDept();
|
|
|
- if(null != dept) {
|
|
|
|
|
|
|
+ if (null != dept) {
|
|
|
redisCache.setCacheObject(Constants.LEADER_VIEW_DEPT_INIT_KEY, dept.getDeptId());
|
|
redisCache.setCacheObject(Constants.LEADER_VIEW_DEPT_INIT_KEY, dept.getDeptId());
|
|
|
redisCache.setCacheObject(getCacheKey(loginUser.getUserId()), dept.getDeptId());
|
|
redisCache.setCacheObject(getCacheKey(loginUser.getUserId()), dept.getDeptId());
|
|
|
}
|
|
}
|