Grails:使用Spring Security插件进行评论的用户评估器 [英] Grails: User evaluator for Commentable with Spring Security plugin

查看:98
本文介绍了Grails:使用Spring Security插件进行评论的用户评估器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在Spring Security中使用可评论的插件。



我无法设法写出正确的



grails.commentable.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

grails.commentable.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插件进行评论的用户评估器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆