明点软件 avatar 明点软件 committed e3f07b4

增加expireSession() 方法

Comments (0)

Files changed (3)

grails-app/controllers/test/TestController.groovy

 import com.mingidea.security.taobao.util.ExSpringSecurityUtils
 
 class TestController {
-
-    def index = { render params}
+    def springSecurityService 
+    def index = { 
+        def user = springSecurityService.currentUser
+        render 'user id: ' + user.id
+    }
     
-    def testGetAllLoggedInUsers = {
-        render ExSpringSecurityUtils.getAllPrincipals() as JSON
+    def expire = {
+        def userId = 1
+        render ExSpringSecurityUtils.expireSession(userId)
     }
 }
-<plugin name='spring-security-taobao' version='0.3.2' grailsVersion='1.3.7 &gt; *'>
+<plugin name='spring-security-taobao' version='0.3.3' grailsVersion='1.3.7 &gt; *'>
   <author>Simon Leung</author>
   <authorEmail>simon.leung@mingidea.com</authorEmail>
   <title>Taobao open authentication support for the Spring Security plugin.</title>

src/groovy/com/mingidea/security/taobao/util/ExSpringSecurityUtils.groovy

     
     /**
      * 
-     * @return 用户不存在返回false,销毁session成功返回true
+     * @return 用户或Session不存在返回false,销毁session成功返回true
      */
     static boolean expireSession(Object userId) {
         SessionRegistry sessionRegistry = getSessionRegistry()
         sessions.each{
             it.expireNow()
         }
+        return sessions.size() > 0
     }
     
     private static SessionRegistry getSessionRegistry() {
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.