Grails with SpringSecurity, check if the current user can access controller / action

前端 未结 8 2251
轮回少年
轮回少年 2021-02-15 13:57

I\'m currently developing a menu for my application that should be able to display only the controllers that the current user can access (requestmap defined in the database).

8条回答
  •  离开以前
    2021-02-15 14:08

    org.grails.plugins.springsecurity.service.AuthenticateService authenticateService = new org.grails.plugins.springsecurity.service.AuthenticateService()
    def isAdmin = authenticateService.ifAllGranted('ROLE_ADMIN')
    
    if(isAdmin) {
       println 'I am Admin'
    }
    

提交回复
热议问题