登录时判断用户状态
This commit is contained in:
parent
788939936d
commit
7421b4b89d
|
@ -5,6 +5,7 @@ import io.metersphere.base.mapper.*;
|
||||||
import io.metersphere.base.mapper.ext.ExtUserMapper;
|
import io.metersphere.base.mapper.ext.ExtUserMapper;
|
||||||
import io.metersphere.base.mapper.ext.ExtUserRoleMapper;
|
import io.metersphere.base.mapper.ext.ExtUserRoleMapper;
|
||||||
import io.metersphere.commons.constants.RoleConstants;
|
import io.metersphere.commons.constants.RoleConstants;
|
||||||
|
import io.metersphere.commons.constants.UserStatus;
|
||||||
import io.metersphere.commons.exception.MSException;
|
import io.metersphere.commons.exception.MSException;
|
||||||
import io.metersphere.commons.user.SessionUser;
|
import io.metersphere.commons.user.SessionUser;
|
||||||
import io.metersphere.commons.utils.CodingUtil;
|
import io.metersphere.commons.utils.CodingUtil;
|
||||||
|
@ -19,6 +20,7 @@ import io.metersphere.dto.UserDTO;
|
||||||
import io.metersphere.dto.UserRoleDTO;
|
import io.metersphere.dto.UserRoleDTO;
|
||||||
import io.metersphere.i18n.Translator;
|
import io.metersphere.i18n.Translator;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.apache.shiro.authc.DisabledAccountException;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
@ -115,7 +117,7 @@ public class UserService {
|
||||||
user.setCreateTime(System.currentTimeMillis());
|
user.setCreateTime(System.currentTimeMillis());
|
||||||
user.setUpdateTime(System.currentTimeMillis());
|
user.setUpdateTime(System.currentTimeMillis());
|
||||||
// 默认1:启用状态
|
// 默认1:启用状态
|
||||||
user.setStatus("1");
|
user.setStatus(UserStatus.NORMAL);
|
||||||
// 密码使用 MD5
|
// 密码使用 MD5
|
||||||
user.setPassword(CodingUtil.md5(user.getPassword()));
|
user.setPassword(CodingUtil.md5(user.getPassword()));
|
||||||
UserExample userExample = new UserExample();
|
UserExample userExample = new UserExample();
|
||||||
|
@ -134,6 +136,9 @@ public class UserService {
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
if (StringUtils.equals(user.getStatus(), UserStatus.DISABLED)) {
|
||||||
|
throw new DisabledAccountException();
|
||||||
|
}
|
||||||
UserDTO userDTO = new UserDTO();
|
UserDTO userDTO = new UserDTO();
|
||||||
BeanUtils.copyProperties(user, userDTO);
|
BeanUtils.copyProperties(user, userDTO);
|
||||||
UserRoleDTO userRole = getUserRole(userId);
|
UserRoleDTO userRole = getUserRole(userId);
|
||||||
|
|
Loading…
Reference in New Issue