我正在使用 死锁 2 与 Playframework 2.1 .
在 getSubject()
我的 DeadboltHandler
的功能我检查用户密码并从数据库中检索用户。
是否可以在我的 Controller 中访问此用户以避免每次请求检索用户两次?
最佳答案
Deadbolt 的开发者史蒂夫向我提出了以下建议:
the trick is to store the user in the context, and then have your controller or deadbolt handler to access it. This allows you to store the user by the actual class, and not have to use getSubject() and cast the resulting Subject to your actual User class.
所以我决定将 User 对象保存在 中参数 -领域 Http.Context.current() 它就像一个魅力!
关于playframework-2.1 - 从 Controller 中访问 Deadbolt 用户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16857677/