Grails : 3.3.0 Spring Security : 3.2.0.M1
我已经对此做了一些研究,我发现(Seeing only your own data in Grails)帖子中的答案可能是我正在寻找的答案,但不知怎么的,它不起作用。
这就是我如何捕获登录用户,并尝试过滤,只是让登录用户查看自己的数据。(这是我的任务控制器)顺便说一句,任务的用途是什么:任务
def index(Integer max) {
def authenticated = getAuthenticatedUser().username
def tasks = User.findAllByUsername(authenticated)
[tasks: tasks]
params.max = Math.min(max ?: 10, 100)
respond Task.list(params), model:[tasks: Task.count()]
}
这是我的任务域
class Task {
transient springSecurityService
String task
Project project
Pic picName
static hasMany = [subTask:Subtask]
static belongsTo =[Project,Pic,User]
}
请给我一些建议,或者让我知道我在哪里做错了!提前感谢!向你问好,喜
发布于 2017-09-08 02:48:09
我是通过在普惠制上喊出“任务”来完成的。对我来说很管用
def authenticated = getAuthenticatedUser().username
def tasks = Task.findAllByLogginUser(authenticated)
params.max = Math.min(max ?: 10, 100)
respond Task.list(params), model:[tasks:tasks] // [tasks:tasks] is to passing tasks into my domain
然后我就从我的域类${tasks}调用
发布于 2017-09-05 09:00:12
我不认为您的需求与Spring安全性无关。
关于“任务的用途是什么:任务”--看起来代码中有两个返回点,所以您需要修复它--在groovy中,如果您位于最后一行,您可以省略“返回”--所以我假设这一行是包含任务列表的模型的返回--但是代码在它之后继续.
然后返回数据+任何其他数据,如计数等。
https://stackoverflow.com/questions/46048546
复制相似问题