Przeglądaj źródła

!285 移除多余的if else
Merge pull request !285 from Hacker/N/A

若依 3 lat temu
rodzic
commit
f392c41f3e

+ 3 - 13
ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/web/filter/kickout/KickoutSessionFilter.java

@@ -94,18 +94,8 @@ public class KickoutSessionFilter extends AccessControlFilter
             // 如果队列里的sessionId数超出最大会话数,开始踢人
             while (deque.size() > maxSession)
             {
-                Serializable kickoutSessionId = null;
                 // 是否踢出后来登录的,默认是false;即后者登录的用户踢出前者登录的用户;
-                if (kickoutAfter)
-                {
-                    // 踢出后者
-                    kickoutSessionId = deque.removeFirst();
-                }
-                else
-                {
-                    // 踢出前者
-                    kickoutSessionId = deque.removeLast();
-                }
+                Serializable kickoutSessionId = kickoutAfter ? deque.removeFirst() : deque.removeLast();
                 // 踢出后再更新下缓存队列
                 cache.put(loginName, deque);
 
@@ -126,7 +116,7 @@ public class KickoutSessionFilter extends AccessControlFilter
             }
 
             // 如果被踢出了,(前者或后者)直接退出,重定向到踢出后的地址
-            if ((Boolean) session.getAttribute("kickout") != null && (Boolean) session.getAttribute("kickout") == true)
+            if (session.getAttribute("kickout") != null && (Boolean) session.getAttribute("kickout") == true)
             {
                 // 退出登录
                 subject.logout();
@@ -183,4 +173,4 @@ public class KickoutSessionFilter extends AccessControlFilter
         // 必须和ehcache缓存配置中的缓存name一致
         this.cache = cacheManager.getCache(ShiroConstants.SYS_USERCACHE);
     }
-}
+}