开发者

Grails Spring security core pre-logout

I'm using Grails Spring Security Core plugin and I need to perform a few actions when logout happens such as delete some class instances related to the user. I tried the following code:

import org.codehaus.groovy.grails.plugins.springsecurity.SpringSecurityUtils
import grails.plugins.springsecurity.Secured

class LogoutController {

def index = {
    def currentUser = currentUser()
    currentUser.searchedResults.each{searched->
        def searchInstance = Search.get(searched.searchId)
        searchInstance.delete()
    }
    redirect uri: SpringSecurityUtils.securityConfig.logout.filterProcessesUrl // '/j_spring_security_logout'
}

private currentUser(){
  开发者_开发问答  return User.get(springSecurityService.principal.id)
}
}

However Grails is giving the error: No such property: User for class: LogoutController My guess is that this is happening because when I installed Spring security core plugin, the LogoutController and LoginController were created in a different package called "default package". Is there any way to overcome this issue? Any help would be appreciated! Thanks


You simply need to import the User class. Something like:

import mypackage.User
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜