deason пре 2 година
родитељ
комит
e8f2ea8b3d

+ 17 - 17
examcloud-core-basic-service/src/main/java/cn/com/qmth/examcloud/core/basic/service/impl/AuthServiceImpl.java

@@ -131,10 +131,10 @@ public class AuthServiceImpl implements AuthService {
         }
 
         StudentEntity student = null;
-
         if (AccountType.STUDENT_PHONE.equals(accountTypeEnum)) {
             student = studentRepo.findBySecurityPhone(accountValue);
             if (null == student) {
+                log.warn("Account_is_wrong... account:{} accountType:{} ip:{}", accountValue, accountType, clientIp);
                 throw new StatusException("003110", "学生不存在");
             }
             loginInfo.setRootOrgId(student.getRootOrgId());
@@ -193,14 +193,15 @@ public class AuthServiceImpl implements AuthService {
         if (AccountType.COMMON_LOGIN_NAME.equals(accountTypeEnum)) {
             UserEntity userEntity = userRepo.findByRootOrgIdAndLoginName(rootOrgId, accountValue);
             if (null == userEntity) {
-                log.warn("WrongAccountOrPsw... rootOrgId:{} account:{} ip:{}", rootOrgId, accountValue, clientIp);
+                log.warn("Account_is_wrong... rootOrgId:{} account:{} accountType:{} ip:{}", rootOrgId, accountValue, accountType, clientIp);
                 throw new StatusException("003004", "账号或密码错误");
             }
             if (null != userEntity.getEnable() && !userEntity.getEnable()) {
+                log.warn("Account_is_disabled... rootOrgId:{} account:{} accountType:{} ip:{}", rootOrgId, accountValue, accountType, clientIp);
                 throw new StatusException("003005", "账号被禁用");
             }
             if (StringUtils.isBlank(password)) {
-                log.warn("WrongAccountOrPsw... rootOrgId:{} account:{} ip:{}", rootOrgId, accountValue, clientIp);
+                log.warn("Account_psw_is_wrong... rootOrgId:{} account:{} accountType:{} ip:{}", rootOrgId, accountValue, accountType, clientIp);
                 throw new StatusException("003203", "账号或密码错误");
             }
 
@@ -218,14 +219,13 @@ public class AuthServiceImpl implements AuthService {
                 String encodePassword = ByteUtil.toHexAscii(bytes);
                 if (!password.equals(userEntity.getPassword()) && !encodePassword.equals(userEntity.getPassword())) {
                     whenLoginError(accountTypeEnum, accountValue, clientIp);
-                    log.warn("WrongAccountOrPsw... rootOrgId:{} account:{} ip:{}", rootOrgId, accountValue, clientIp);
+                    log.warn("Account_psw_is_wrong... rootOrgId:{} userId:{} account:{} accountType:{} ip:{}", rootOrgId, user.getUserId(), accountValue, accountType, clientIp);
                     throw new StatusException("003003", "账号或密码错误");
                 }
             } else {
                 // 系统级别登陆限制
                 if (AccountType.COMMON_LOGIN_NAME.equals(accountTypeEnum)) {
-                    Boolean commonLoginLimit = (Boolean) systemPropertyService
-                            .get("COMMON_LOGIN_LIMIT");
+                    Boolean commonLoginLimit = (Boolean) systemPropertyService.get("COMMON_LOGIN_LIMIT");
                     if (commonLoginLimit) {
                         throw new StatusException("003506", "系统维护中... ...");
                     }
@@ -234,7 +234,7 @@ public class AuthServiceImpl implements AuthService {
                 String encodePassword = ByteUtil.toHexAscii(bytes);
                 if (!password.equals(userEntity.getPassword()) && !encodePassword.equals(userEntity.getPassword())) {
                     whenLoginError(accountTypeEnum, accountValue, clientIp);
-                    log.warn("WrongAccountOrPsw... rootOrgId:{} account:{} ip:{}", rootOrgId, accountValue, clientIp);
+                    log.warn("Account_psw_is_wrong... rootOrgId:{} userId:{} account:{} accountType:{} ip:{}", rootOrgId, user.getUserId(), accountValue, accountType, clientIp);
                     throw new StatusException("003003", "账号或密码错误");
                 }
             }
@@ -250,14 +250,12 @@ public class AuthServiceImpl implements AuthService {
 
             // 学生学号登录
             if (AccountType.STUDENT_CODE.equals(accountTypeEnum)) {
-                StudentCodeEntity scEntity = studentCodeRepo
-                        .findByStudentCodeAndRootOrgId(accountValue, rootOrgId);
+                StudentCodeEntity scEntity = studentCodeRepo.findByStudentCodeAndRootOrgId(accountValue, rootOrgId);
                 if (null == scEntity) {
-                    log.warn("[S] WrongAccountOrPsw... rootOrgId:{} account:{} ip:{}", rootOrgId, accountValue, clientIp);
+                    log.warn("Account_is_wrong... rootOrgId:{} account:{} accountType:{} ip:{}", rootOrgId, accountValue, accountType, clientIp);
                     throw new StatusException("003009", "账号或密码错误");
                 }
-                student = GlobalHelper.getEntity(studentRepo, scEntity.getStudentId(),
-                        StudentEntity.class);
+                student = GlobalHelper.getEntity(studentRepo, scEntity.getStudentId(), StudentEntity.class);
             }
 
             // 学生身份证号登录
@@ -266,16 +264,17 @@ public class AuthServiceImpl implements AuthService {
             }
 
             if (null == student) {
-                log.warn("[S] WrongAccountOrPsw... rootOrgId:{} account:{} ip:{}", rootOrgId, accountValue, clientIp);
+                log.warn("Account_is_wrong... rootOrgId:{} account:{} accountType:{} ip:{}", rootOrgId, accountValue, accountType, clientIp);
                 throw new StatusException("003110", "账号或密码错误");
             }
+
             if (null != student.getEnable() && !student.getEnable()) {
+                log.warn("Account_is_disabled... rootOrgId:{} account:{} accountType:{} ip:{}", rootOrgId, accountValue, accountType, clientIp);
                 throw new StatusException("003005", "账户被禁用");
             }
 
             // 验证码登录
-            if (AccountType.STUDENT_PHONE.equals(accountTypeEnum)
-                    && StringUtils.isNotBlank(smsCode)) {
+            if (AccountType.STUDENT_PHONE.equals(accountTypeEnum) && StringUtils.isNotBlank(smsCode)) {
                 try {
                     smsCodeService.checkSmsCode(accountValue, smsCode);
                 } catch (Exception e) {
@@ -283,17 +282,18 @@ public class AuthServiceImpl implements AuthService {
                     throw e;
                 }
             }
+
             // 密码登录
             else {
                 if (StringUtils.isBlank(password)) {
-                    log.warn("[S] WrongAccountOrPsw... rootOrgId:{} account:{} ip:{}", rootOrgId, accountValue, clientIp);
+                    log.warn("Account_psw_is_wrong... rootOrgId:{} userId:{} account:{} accountType:{} ip:{}", rootOrgId, student.getId(), accountValue, accountType, clientIp);
                     throw new StatusException("003203", "账号或密码错误");
                 }
                 byte[] bytes = SHA256.encode(student.getIdentityNumber() + password);
                 String encodePassword = ByteUtil.toHexAscii(bytes);
                 if (!password.equals(student.getPassword()) && !encodePassword.equals(student.getPassword())) {
                     whenLoginError(accountTypeEnum, accountValue, clientIp);
-                    log.warn("[S] WrongAccountOrPsw... rootOrgId:{} account:{} ip:{}", rootOrgId, accountValue, clientIp);
+                    log.warn("Account_psw_is_wrong... rootOrgId:{} userId:{} account:{} accountType:{} ip:{}", rootOrgId, student.getId(), accountValue, accountType, clientIp);
                     throw new StatusException("003003", "账号或密码错误");
                 }
             }