Access Deadbolt user from inside the controller

I am using Deadbolt 2 with Playframework 2.1 .

In the getSubject() function of my DeadboltHandler I check the user password and retrieve the user from the database.

Is it possible to access this user in my controllers in order to avoid a user double request for a request?

+6
source share
1 answer

Steve, the developer of Deadbolt, suggested the following to me:

the trick is to keep the user in context and then use your controller or deadbolt handler to access it. This allows you to store the user by the actual class, rather than using getSubject () and pouring the resulting object into your actual user class.

So, I decided to save the User object in args -Field Http.Context.current () , and it works like a charm!

+3
source

Source: https://habr.com/ru/post/946260/


All Articles