i want to get the current user who is logged in and i used this way and i jave injected the SpringsecurityService and i am getting this error like "Caused by No such property: principal for class: grails.plugin.springsecurity.SpringSecurityService Possible solutions: principal".
Organization.controller
SpringSecurityService springSecurityService
def user = springSecurityService.get(SpringSecurityService.principal.id)
Inject springSecurityService and call getCurrentUser()
Example:
class OrganizationController {
def springSecurityService
def myAction(){
User user = springSecurityService.getCurrentUser() //where "User" is is user domain class or you can "def" also
}
}
}
user
will hold your current logged in user object.
Hope this will helps you