|
@@ -179,8 +179,7 @@ public class AuthServiceImpl implements AuthService {
|
|
|
}
|
|
|
// 学生身份证号登录
|
|
|
else if (AccountType.STUDENT_IDENTITY_NUMBER.equals(accountTypeEnum)) {
|
|
|
- student = studentRepo.findByIdentityNumberAndRootOrgId(accountValue,
|
|
|
- rootOrg.getId());
|
|
|
+ student = studentRepo.findByIdentityNumberAndRootOrgId(accountValue, rootOrg.getId());
|
|
|
}
|
|
|
|
|
|
if (null == student) {
|
|
@@ -239,8 +238,8 @@ public class AuthServiceImpl implements AuthService {
|
|
|
* @param ip
|
|
|
*/
|
|
|
private void whenPasswordError(AccountType accountType, String accountValue, String ip) {
|
|
|
- String key = new StringBuilder("$_PW_ERR_").append(accountType.getCode()).append("_")
|
|
|
- .append(accountValue).append("_").append(ip).toString();
|
|
|
+ String key = new StringBuilder("$_PW_ERR_").append(accountType.getCode()).append("_").append(accountValue)
|
|
|
+ .append("_").append(ip).toString();
|
|
|
|
|
|
Integer times = redisClient.get(key, Integer.class);
|
|
|
if (null != times) {
|
|
@@ -262,8 +261,8 @@ public class AuthServiceImpl implements AuthService {
|
|
|
* @return
|
|
|
*/
|
|
|
private boolean limited(AccountType accountType, String accountValue, String ip) {
|
|
|
- String key = new StringBuilder("$_PW_ERR_").append(accountType.getCode()).append("_")
|
|
|
- .append(accountValue).append("_").append(ip).toString();
|
|
|
+ String key = new StringBuilder("$_PW_ERR_").append(accountType.getCode()).append("_").append(accountValue)
|
|
|
+ .append("_").append(ip).toString();
|
|
|
|
|
|
Integer times = redisClient.get(key, Integer.class);
|
|
|
|
|
@@ -314,6 +313,9 @@ public class AuthServiceImpl implements AuthService {
|
|
|
* @param orgId
|
|
|
*/
|
|
|
private void setSecurityIp(User user, Long orgId) {
|
|
|
+ if (null == orgId) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
String key = "IP_" + orgId;
|
|
|
|
|
|
String clientIp = user.getClientIp();
|
|
@@ -374,8 +376,7 @@ public class AuthServiceImpl implements AuthService {
|
|
|
private String buildUserKey(User user) {
|
|
|
Long rootOrgId = user.getRootOrgId();
|
|
|
UserType userType = user.getUserType();
|
|
|
- String key = StringUtil.join("U_", userType.getCode(), "_", rootOrgId, "_",
|
|
|
- user.getUserId());
|
|
|
+ String key = StringUtil.join("U_", userType.getCode(), "_", rootOrgId, "_", user.getUserId());
|
|
|
return key;
|
|
|
}
|
|
|
|
|
@@ -405,8 +406,8 @@ public class AuthServiceImpl implements AuthService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public User thirdPartyAccess(Long rootOrgId, String loginName, String appId, String timestamp,
|
|
|
- String token) throws StatusException {
|
|
|
+ public User thirdPartyAccess(Long rootOrgId, String loginName, String appId, String timestamp, String token,
|
|
|
+ String clientIp) throws StatusException {
|
|
|
|
|
|
OrgEntity rootOrg = orgRepo.findOne(rootOrgId);
|
|
|
if (null == rootOrg) {
|
|
@@ -455,8 +456,15 @@ public class AuthServiceImpl implements AuthService {
|
|
|
List<Role> roleList = getUserRoles(userEntity.getId());
|
|
|
user.setRoleList(roleList);
|
|
|
|
|
|
+ user.setClientIp(clientIp);
|
|
|
setSession(user);
|
|
|
|
|
|
+ boolean isLcUser = isLcUser(user);
|
|
|
+
|
|
|
+ if (isLcUser) {
|
|
|
+ setSecurityIp(user, userEntity.getOrgId());
|
|
|
+ }
|
|
|
+
|
|
|
return user;
|
|
|
}
|
|
|
|
|
@@ -498,8 +506,7 @@ public class AuthServiceImpl implements AuthService {
|
|
|
if (null == roleEntity) {
|
|
|
throw new StatusException("B-002002", "roleId is wrong. roleId=" + roleId);
|
|
|
}
|
|
|
- Role role = new Role(roleEntity.getId(), roleEntity.getCode(),
|
|
|
- roleEntity.getName());
|
|
|
+ Role role = new Role(roleEntity.getId(), roleEntity.getCode(), roleEntity.getName());
|
|
|
roleList.add(role);
|
|
|
}
|
|
|
}
|