我试图在Spring Security中使用可评论的插件。
我无法设法写出正确的
grailsmentable.poster.evaluator
我试过{User.get(springSecurityService.principal.id)},,但是从CommentController, User和springSecurity似乎无法访问。
我应该怎么做? 对于 springSecurityService.principal.id ,因为 springSecurityService 没有依赖关系注入字段,所以你无法工作需要调用 springSecurityService.principal.id 调用 - org.springframework.security.core.context.SecurityContextHolder.context.authentication.principal.id
要解决用户的问题,您需要包含完整的类名称。所以结合起来,这应该是
{com.yourcompany.yourapp.User.get(org.springframework.security.core.context .SecurityContextHolder.context.authentication.principal.id)}
I am trying to use the commentable plugin with Spring Security.
I can't manage to write the right
grailsmentable.poster.evaluator
I tried {User.get(springSecurityService.principal.id)}, but from the CommentController, both User and springSecurity seems unaccessible.
What should I do?
解决方案For springSecurityService.principal.id since there's no dependency injection field for springSecurityService it can't work, so you need to call what springSecurityService.principal.id calls - org.springframework.security.core.context.SecurityContextHolder.context.authentication.principal.id
To fix the problem with User, you'll need the full class name with package. So combined, this should be
{com.yourcompany.yourapp.User.get(org.springframework.security.core.context.SecurityContextHolder.context.authentication.principal.id)}
更多推荐
Grails:使用Spring Security插件进行评论的用户评估器
发布评论