How to get id of the current user logged in grails?

前端 未结 3 920
失恋的感觉
失恋的感觉 2021-01-18 18:24

I want to display the info about the user logged in like his details etc given during sign up ...how to do it ?? As iam new to grails plz help! iam using Spring security plu

3条回答
  •  余生分开走
    2021-01-18 19:03

    Well you can use the springSecurityService to get some user information in a controller:

        class MyController {
          def springSecurityService
    
          def myAction() {
            def principal = springSecurityService.principal
            String username = principal.username
            ...
          }
         }
    

    Or in a gsp

        
    

    It is a pretty general question.

提交回复
热议问题