Grails:使用Spring Security插件进行评论的用户评估器

编程入门 行业动态 更新时间:2024-10-09 02:23:55
本文介绍了Grails:使用Spring Security插件进行评论的用户评估器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我试图在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插件进行评论的用户评估器

本文发布于:2023-11-28 18:50:13,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:插件   用户   Grails   Spring   Security

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!