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

前端 未结 3 919
失恋的感觉
失恋的感觉 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:06

    Define (in a controller, or service where you need user id):

    SpringSecurityService springSecurityService
    

    and try:

    springSecurityService.currentUser.id //loads user from db, and returns its id
    

    or:

    springSecurityService.principal.id //if you need just id
    

提交回复
热议问题