|
@@ -108,17 +108,17 @@ public class AuthServiceImpl implements AuthService {
|
|
|
String imgCode = loginInfo.getImgCode();
|
|
|
|
|
|
if (StringUtils.isBlank(accountType)) {
|
|
|
- throw new StatusException("B-001201", "accountType is null");
|
|
|
+ throw new StatusException("001201", "accountType is null");
|
|
|
}
|
|
|
if (StringUtils.isBlank(accountValue)) {
|
|
|
- throw new StatusException("B-001202", "accountValue is null");
|
|
|
+ throw new StatusException("001202", "accountValue is null");
|
|
|
}
|
|
|
|
|
|
AccountType accountTypeEnum = null;
|
|
|
try {
|
|
|
accountTypeEnum = AccountType.valueOf(accountType);
|
|
|
} catch (Exception e) {
|
|
|
- throw new StatusException("B-001204", "accountType is wrong");
|
|
|
+ throw new StatusException("001204", "accountType is wrong");
|
|
|
}
|
|
|
|
|
|
// 系统级别登陆限制
|
|
@@ -127,12 +127,12 @@ public class AuthServiceImpl implements AuthService {
|
|
|
|| AccountType.STUDENT_CODE.equals(accountTypeEnum)) {
|
|
|
Boolean stuClientLoginLimit = (Boolean) sysConfigService.get("STU_CLIENT_LOGIN_LIMIT");
|
|
|
if (stuClientLoginLimit) {
|
|
|
- throw new StatusException("B-001505", "系统维护中... ...");
|
|
|
+ throw new StatusException("001505", "系统维护中... ...");
|
|
|
}
|
|
|
} else if (AccountType.COMMON_LOGIN_NAME.equals(accountTypeEnum)) {
|
|
|
Boolean commonLoginLimit = (Boolean) sysConfigService.get("COMMON_LOGIN_LIMIT");
|
|
|
if (commonLoginLimit) {
|
|
|
- throw new StatusException("B-001506", "系统维护中... ...");
|
|
|
+ throw new StatusException("001506", "系统维护中... ...");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -140,10 +140,10 @@ public class AuthServiceImpl implements AuthService {
|
|
|
if (StringUtils.isNotBlank(sessionId) && StringUtils.isNotBlank(imgCode)) {
|
|
|
String rightImgCode = redisClient.get("$_IMG_" + sessionId, String.class);
|
|
|
if (null == rightImgCode || !rightImgCode.equalsIgnoreCase(imgCode)) {
|
|
|
- throw new StatusException("B-002303", "验证码错误");
|
|
|
+ throw new StatusException("002303", "验证码错误");
|
|
|
}
|
|
|
} else if (5 < errorTimes) {
|
|
|
- throw new StatusException("B-001205", "登陆失败次数已达到上限,请5分钟后重试");
|
|
|
+ throw new StatusException("001205", "登陆失败次数已达到上限,请5分钟后重试");
|
|
|
}
|
|
|
|
|
|
StudentEntity student = null;
|
|
@@ -151,7 +151,7 @@ public class AuthServiceImpl implements AuthService {
|
|
|
if (AccountType.STUDENT_PHONE.equals(accountTypeEnum)) {
|
|
|
student = studentRepo.findBySecurityPhone(accountValue);
|
|
|
if (null == student) {
|
|
|
- throw new StatusException("B-001110", "学生不存在");
|
|
|
+ throw new StatusException("001110", "学生不存在");
|
|
|
}
|
|
|
loginInfo.setRootOrgId(student.getRootOrgId());
|
|
|
}
|
|
@@ -160,20 +160,20 @@ public class AuthServiceImpl implements AuthService {
|
|
|
OrgEntity rootOrg = null;
|
|
|
if (null == rootOrgId) {
|
|
|
if (StringUtils.isBlank(loginInfo.getDomain())) {
|
|
|
- throw new StatusException("B-001001", "domain,rootOrgId 必须有一个不为空");
|
|
|
+ throw new StatusException("001001", "domain,rootOrgId 必须有一个不为空");
|
|
|
}
|
|
|
|
|
|
try {
|
|
|
rootOrg = orgRepo.findByParentIdIsNullAndDomainName(loginInfo.getDomain());
|
|
|
rootOrgId = rootOrg.getId();
|
|
|
} catch (Exception e) {
|
|
|
- throw new StatusException("B-001002", "机构不存在", e);
|
|
|
+ throw new StatusException("001002", "机构不存在", e);
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
rootOrg = GlobalHelper.getEntity(orgRepo, Long.valueOf(rootOrgId), OrgEntity.class);
|
|
|
if (null == rootOrg) {
|
|
|
- throw new StatusException("B-001002", "机构不存在");
|
|
|
+ throw new StatusException("001002", "机构不存在");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -181,7 +181,7 @@ public class AuthServiceImpl implements AuthService {
|
|
|
if (StringUtils.isNotBlank(accessibleRootOrgIds)) {
|
|
|
accessibleRootOrgIds = "," + accessibleRootOrgIds + ",";
|
|
|
if (!accessibleRootOrgIds.contains("," + rootOrg.getId() + ",")) {
|
|
|
- throw new StatusException("B-001101", "系统维护中... ...");
|
|
|
+ throw new StatusException("001101", "系统维护中... ...");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -194,13 +194,13 @@ public class AuthServiceImpl implements AuthService {
|
|
|
if (AccountType.COMMON_LOGIN_NAME.equals(accountTypeEnum)) {
|
|
|
UserEntity userEntity = userRepo.findByRootOrgIdAndLoginName(rootOrgId, accountValue);
|
|
|
if (null == userEntity) {
|
|
|
- throw new StatusException("B-001004", "账号或密码错误");
|
|
|
+ throw new StatusException("001004", "账号或密码错误");
|
|
|
}
|
|
|
if (null != userEntity.getEnable() && !userEntity.getEnable()) {
|
|
|
- throw new StatusException("B-001005", "账号被禁用");
|
|
|
+ throw new StatusException("001005", "账号被禁用");
|
|
|
}
|
|
|
if (StringUtils.isBlank(password)) {
|
|
|
- throw new StatusException("B-001203", "账号或密码错误");
|
|
|
+ throw new StatusException("001203", "账号或密码错误");
|
|
|
}
|
|
|
|
|
|
user.setUserId(userEntity.getId());
|
|
@@ -216,12 +216,12 @@ public class AuthServiceImpl implements AuthService {
|
|
|
String encodePassword = ByteUtil.toHexAscii(bytes);
|
|
|
if (!encodePassword.equals(userEntity.getPassword())) {
|
|
|
whenLoginError(accountTypeEnum, accountValue, clientIp);
|
|
|
- throw new StatusException("B-001003", "账号或密码错误");
|
|
|
+ throw new StatusException("001003", "账号或密码错误");
|
|
|
}
|
|
|
} else {
|
|
|
if (!password.equals(userEntity.getPassword())) {
|
|
|
whenLoginError(accountTypeEnum, accountValue, clientIp);
|
|
|
- throw new StatusException("B-001003", "账号或密码错误");
|
|
|
+ throw new StatusException("001003", "账号或密码错误");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -237,10 +237,10 @@ public class AuthServiceImpl implements AuthService {
|
|
|
}
|
|
|
|
|
|
if (null == student) {
|
|
|
- throw new StatusException("B-001110", "账号或密码错误");
|
|
|
+ throw new StatusException("001110", "账号或密码错误");
|
|
|
}
|
|
|
if (null != student.getEnable() && !student.getEnable()) {
|
|
|
- throw new StatusException("B-001005", "账户被禁用");
|
|
|
+ throw new StatusException("001005", "账户被禁用");
|
|
|
}
|
|
|
|
|
|
// 验证码登录
|
|
@@ -256,12 +256,12 @@ public class AuthServiceImpl implements AuthService {
|
|
|
// 密码登录
|
|
|
else {
|
|
|
if (StringUtils.isBlank(password)) {
|
|
|
- throw new StatusException("B-001203", "账号或密码错误");
|
|
|
+ throw new StatusException("001203", "账号或密码错误");
|
|
|
}
|
|
|
String rightPassword = student.getPassword();
|
|
|
if (!rightPassword.equals(password)) {
|
|
|
whenLoginError(accountTypeEnum, accountValue, clientIp);
|
|
|
- throw new StatusException("B-001003", "账号或密码错误");
|
|
|
+ throw new StatusException("001003", "账号或密码错误");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -291,7 +291,7 @@ public class AuthServiceImpl implements AuthService {
|
|
|
// 验证码为空时,发送验证码
|
|
|
else {
|
|
|
smsCodeService.sendSmsCode(phone);
|
|
|
- throw new StatusException("B-001100", "请输入短信验证码");
|
|
|
+ throw new StatusException("001100", "请输入短信验证码");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -308,7 +308,7 @@ public class AuthServiceImpl implements AuthService {
|
|
|
// 学习中心禁用时,学习中心用户禁止登录
|
|
|
if (1 == user.getRoleList().size() && isLcUser) {
|
|
|
if (null != org && !org.getEnable()) {
|
|
|
- throw new StatusException("B-001008", "学习中心被禁用");
|
|
|
+ throw new StatusException("001008", "学习中心被禁用");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -505,11 +505,11 @@ public class AuthServiceImpl implements AuthService {
|
|
|
int sessionTimeout = PropertyHolder.getInt(PropKeys.SESSION_TIMEOUT, 3600);
|
|
|
User user = redisClient.get(key, User.class, sessionTimeout);
|
|
|
if (null == user) {
|
|
|
- throw new StatusException("B-001012", "未登录");
|
|
|
+ throw new StatusException("001012", "未登录");
|
|
|
}
|
|
|
|
|
|
if (!user.getToken().equals(token)) {
|
|
|
- throw new StatusException("B-001012", "token错误");
|
|
|
+ throw new StatusException("001012", "token错误");
|
|
|
}
|
|
|
|
|
|
return user;
|
|
@@ -521,26 +521,26 @@ public class AuthServiceImpl implements AuthService {
|
|
|
|
|
|
OrgEntity rootOrg = GlobalHelper.getEntity(orgRepo, rootOrgId, OrgEntity.class);
|
|
|
if (null == rootOrg) {
|
|
|
- throw new StatusException("B-001002", "机构不存在");
|
|
|
+ throw new StatusException("001002", "机构不存在");
|
|
|
}
|
|
|
|
|
|
ThirdPartyAccessEntity thirdPartyAccess = GlobalHelper.getEntity(thirdPartyAccessRepo,
|
|
|
new ThirdPartyAccessPK(rootOrgId, appId), ThirdPartyAccessEntity.class);
|
|
|
|
|
|
if (null == thirdPartyAccess) {
|
|
|
- throw new StatusException("B-001201", "第三方系统接入信息未配置");
|
|
|
+ throw new StatusException("001201", "第三方系统接入信息未配置");
|
|
|
}
|
|
|
|
|
|
long timestampLong = 0L;
|
|
|
try {
|
|
|
timestampLong = Long.parseLong(timestamp);
|
|
|
} catch (Exception e) {
|
|
|
- throw new StatusException("B-001202", "timestamp错误");
|
|
|
+ throw new StatusException("001202", "timestamp错误");
|
|
|
}
|
|
|
|
|
|
long currentTimeMillis = System.currentTimeMillis();
|
|
|
if (Math.abs(currentTimeMillis - timestampLong) > thirdPartyAccess.getTimeRange()) {
|
|
|
- throw new StatusException("B-001203", "timestamp超出时间差范围");
|
|
|
+ throw new StatusException("001203", "timestamp超出时间差范围");
|
|
|
}
|
|
|
|
|
|
String secretKey = thirdPartyAccess.getSecretKey();
|
|
@@ -549,12 +549,12 @@ public class AuthServiceImpl implements AuthService {
|
|
|
String hexAscii = ByteUtil.toHexAscii(bytes);
|
|
|
|
|
|
if (!hexAscii.equalsIgnoreCase(token)) {
|
|
|
- throw new StatusException("B-001204", "token校验失败");
|
|
|
+ throw new StatusException("001204", "token校验失败");
|
|
|
}
|
|
|
|
|
|
UserEntity userEntity = userRepo.findByRootOrgIdAndLoginName(rootOrgId, loginName);
|
|
|
if (userEntity == null) {
|
|
|
- throw new StatusException("B-001205", "用户不存在");
|
|
|
+ throw new StatusException("001205", "用户不存在");
|
|
|
}
|
|
|
|
|
|
User user = new User();
|
|
@@ -611,7 +611,7 @@ public class AuthServiceImpl implements AuthService {
|
|
|
Long roleId = cur.getRoleId();
|
|
|
RoleEntity roleEntity = GlobalHelper.getEntity(roleRepo, roleId, RoleEntity.class);
|
|
|
if (null == roleEntity) {
|
|
|
- throw new StatusException("B-002002", "roleId is wrong. roleId=" + roleId);
|
|
|
+ throw new StatusException("002002", "roleId is wrong. roleId=" + roleId);
|
|
|
}
|
|
|
Role role = new Role(roleEntity.getId(), roleEntity.getCode(),
|
|
|
roleEntity.getName());
|