Переглянути джерело

景聚庭-移动端多个钉钉登录相同系统账号时覆盖钉钉id,登录退出时清除钉钉id

huangguoce 1 тиждень тому
батько
коміт
59c755c5e6

+ 20 - 11
jeeplus-auth/src/main/java/com/jeeplus/auth/controller/LoginController.java

@@ -458,6 +458,14 @@ public class LoginController {
             redisUtils.delete ( CacheNames.USER_CACHE_TOKEN, userDTO.getToken() );
             redisUtils.delete ( CacheNames.USER_CACHE_ONLINE_USERS, userDTO.getToken() );
         }
+        //清除钉钉绑定id
+        if(StringUtils.isNotBlank(currentUserDTO.getDdId()) && StringUtils.isNotBlank(currentUserDTO.getId())){
+            UserDTO bindUserDTO = new UserDTO();
+            bindUserDTO.setId(currentUserDTO.getId());
+            bindUserDTO.setDdId("");
+            userApi.updateUserById(bindUserDTO);
+        }
+
         return ResponseEntity.ok ( "退出成功" );
     }
 
@@ -618,16 +626,16 @@ public class LoginController {
 
         UserDTO userDTO = userApi.getByLoginName(username, tenantId);
 
-        if ("妯婅帀".equals(userDTO.getName())) {
+        if("樊莉".equals(userDTO.getName())){
 
-            List<UserDTO> onLineUserList = SpringUtil.getBean(IUserApi.class).getOnLineUserList("榛勭幃", "10002");
-            if (!onLineUserList.isEmpty()) {
-                throw new DisabledException("褰撳墠榛勭幃宸茬櫥褰曠郴缁燂紝" + ErrorConstants.LOGIN_ERROR);
+            List<UserDTO> onLineUserList = SpringUtil.getBean(IUserApi.class).getOnLineUserList("黄玮", "10002");
+            if(!onLineUserList.isEmpty()){
+                throw new DisabledException ( "当前黄玮已登录系统," + ErrorConstants.LOGIN_ERROR );
             }
-        } else if ("榛勭幃".equals(userDTO.getName())) {
-            List<UserDTO> onLineUserList = SpringUtil.getBean(IUserApi.class).getOnLineUserList("妯婅帀", "10002");
-            if (!onLineUserList.isEmpty()) {
-                throw new DisabledException("褰撳墠妯婅帀宸茬櫥褰曠郴缁燂紝" + ErrorConstants.LOGIN_ERROR);
+        }else if("黄玮".equals(userDTO.getName())){
+            List<UserDTO> onLineUserList = SpringUtil.getBean(IUserApi.class).getOnLineUserList("樊莉", "10002");
+            if(!onLineUserList.isEmpty()){
+                throw new DisabledException ( "当前樊莉已登录系统," + ErrorConstants.LOGIN_ERROR );
             }
         }
 
@@ -662,9 +670,10 @@ public class LoginController {
         if (CommonConstants.NO.equals(userDTO.getLoginFlag())) {
             throw new LockedException(ErrorConstants.LOGIN_ERROR_FORBIDDEN);
         }
-        if (StringUtils.isNotBlank(userDTO.getDdId()) && !bindInfo.getDdId().equals(userDTO.getDdId())) {
-            return ResponseEntity.badRequest().body("Current system account is already bound to another DingTalk account");
-        }
+        //此处用作钉钉绑定唯一系统账号的拦截
+        //if (StringUtils.isNotBlank(userDTO.getDdId()) && !bindInfo.getDdId().equals(userDTO.getDdId())) {
+        //    return ResponseEntity.badRequest().body("Current system account is already bound to another DingTalk account");
+        //}
         UserDTO bindUserDTO = new UserDTO();
         bindUserDTO.setId(userDTO.getId());
         bindUserDTO.setDdId(bindInfo.getDdId());

+ 2 - 0
jeeplus-modules/jeeplus-system/src/main/java/com/jeeplus/sys/mapper/xml/UserMapper.xml

@@ -746,6 +746,8 @@ select a.id, a.company_id as "companyDTO.id", a.office_id as "officeDTO.id", a.l
         SELECT
             login_name, password
         FROM sys_user a where dd_id = #{ddId} and tenant_id = #{tenantId} and del_flag = '0'
+        ORDER BY login_date DESC
+            limit 1
     </select>
     <select id="getAllOpenIds" resultType="java.lang.String">
         SELECT open_id FROM sys_user WHERE del_flag = 0 and open_id is not null