登录时将grails域变量存储在springsecurity会话对象中

登录时将grails域变量存储在springsecurity会话对象中,grails,spring-security,Grails,Spring Security,我正在使用spring安全性。我有一个用户对象,它不包含当用户登录时需要在多个页面上显示的变量。这些域看起来像: class User { String username String password boolean enabled boolean accountExpired boolean accountLocked boolean passwordExpired Integer securityQuestion String

我正在使用spring安全性。我有一个用户对象,它不包含当用户登录时需要在多个页面上显示的变量。这些域看起来像:

class User {
    String username
    String password
    boolean enabled
    boolean accountExpired
    boolean accountLocked
    boolean passwordExpired
    Integer securityQuestion
    String securityAnswer

}

class Profile {
   User user
   String displayMe  //this is actually a calculated transient string based on some other info
}
Profile和User是独立的类。我需要在会话中存储profile.displayMe,以便在某些GSP中使用。我没有一个大的用户域,因为域模型有几个配置文件类型,将它们组合成一个巨大的用户域是很混乱的。合并域以获得User.displayMe不是一个选项


在springsecurity中,我将在会话中的何处存储profile.displayMe?我还不太熟悉springsecurity,因此我需要一些特定的帮助,例如“在LoginController.groovy(springsecurity的默认登录控制器)的auth方法中”。

实现这一点的最佳方法是使用自定义UserDetailsService。如果您使用的是2.0或1.x,请参阅文档