playframework-2.1 - 从 Controller 中访问 Deadbolt 用户

标签 playframework-2.1 deadbolt

我正在使用 死锁 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/

相关文章:

java - 在weblogic上部署play框架

java - 玩! 2.1-RC2 没有静态引用的 JavaForms validate()

playframework-2.0 - Playframework 2.2 解析器

java - Play框架授权Java

java - 在 Play 框架 2.1.4 中使用 Helpers.callAction 与没有静态方法的 Controller

java - Ebean/Play 的 OptimisticLockException

java - 如何访问 Deadbolt2 处理程序中的用户 session

java - Deadbolt 2 : Controlling restrictions with DB settings, 完全

java - egit->eclipse正确导入general_project->Java_project

playframework - Play 框架模板自动导入模型。_ 等等