LiGuang пре 3 година
родитељ
комит
a4c32f79b6

+ 12 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/LoginController.java

@@ -5,6 +5,7 @@ import cn.hutool.crypto.SecureUtil;
 import com.alibaba.fastjson.JSONObject;
 import com.aliyuncs.exceptions.ClientException;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -30,6 +31,7 @@ import org.jeecg.modules.message.websocket.Chat;
 import org.jeecg.modules.message.websocket.WebSocket;
 import org.jeecg.modules.system.entity.SysDepart;
 import org.jeecg.modules.system.entity.SysUser;
+import org.jeecg.modules.system.entity.SysUserRole;
 import org.jeecg.modules.system.model.SysLoginModel;
 import org.jeecg.modules.system.service.*;
 import org.jeecg.modules.system.util.*;
@@ -68,6 +70,8 @@ public class LoginController {
 	@Autowired
 	private ISysDepartService sysDepartService;
 	@Autowired
+	private  ISysUserRoleService sysUserRoleService;
+	@Autowired
 	private ISysDictService sysDictService;
 	@Resource
 	private BaseCommonService baseCommonService;
@@ -133,7 +137,6 @@ public class LoginController {
 		if(!result.isSuccess()) {
 			return result;
 		}
-
 		//2. 校验用户名或密码是否正确
 		if (password!=null&&!password.equals("")) {
 			String userpassword = PasswordUtil.encrypt(sysUser.getUsername(), password, sysUser.getSalt());
@@ -142,6 +145,14 @@ public class LoginController {
 				result.error500("用户名或密码错误");
 				return result;
 			}
+		}if(sysUser!=null){
+			List<SysUserRole> userRole = sysUserRoleService.list(new QueryWrapper<SysUserRole>().lambda().eq(SysUserRole::getUserId, sysUser.getId()));
+			for (SysUserRole str:userRole){
+				if (str.getRoleId().equals("1473241527673765890")){
+					result.error500("暂无登录权限!请联系管理员");
+					return result;
+				}
+			}
 		}
 		//用户登录信息
 		userInfo(sysUser, result);