wangwei il y a 6 ans
Parent
commit
9092830468

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

@@ -181,9 +181,8 @@ public class AuthServiceImpl implements AuthService {
 			user.setOrgName(org.getName());
 		}
 
-		// 学习中心角色的用户
-		if (1 == user.getRoleList().size()
-				&& user.getRoleList().get(0).getRoleCode().equals(RoleMeta.LC_USER.name())) {
+		// 学习中心禁用时,学习中心用户禁止登录
+		if (1 == user.getRoleList().size() && isLcUser(user)) {
 			if (null != org && !org.getEnable()) {
 				throw new StatusException("B-001008", "学习中心被禁用");
 			}
@@ -194,6 +193,24 @@ public class AuthServiceImpl implements AuthService {
 		return user;
 	}
 
+	/**
+	 * 是否是学习中心角色
+	 *
+	 * @author WANGWEI
+	 * @param user
+	 * @return
+	 */
+	private boolean isLcUser(User user) {
+		List<Role> roleList = user.getRoleList();
+
+		for (Role role : roleList) {
+			if (role.getRoleCode().equals(RoleMeta.LC_USER.name())) {
+				return true;
+			}
+		}
+		return false;
+	}
+
 	/**
 	 * 构建key
 	 *