schaloner/deadbolt-2 — pull request #3 by jblipphaus (2012-04-03 07:42:18+00:00)
Title: Bugs / Changes

Hello Steve,

I've looked into deadbolt-2 for one of my projects and it works fine, but I found some bugs/needed changes.

1) I found out that sometimes the method 'getRoleHolder(Http.Context context)' from the DeadboltHandler is called directly from inside Deadbolt.java and so not allowing caching. I changed this to a call of the getRoleHolder method in RequestUtils.

2) I needed a simple way to get the current RoleHolder in my HTML templates, so I added the method getRoleHolder() to TemplateUtils.
Perhaps you'll find another location more appropriate.

3) When getting a result through my DeadboltHandler I recognized, that the current Http.Context seems to "get lost", for example the @Messages("foo") call does not work any longer. So I had to add the following to the DeadboltHandler in my project:

public Result onAccessFailure(Http.Context context, String s) {
Http.Context.current.set(context); // <-- this is needed to have a current Http.Context
return ok(views.html.index.render());
}

The same with the 'beforeRoleCheck' method.

I have 1) and 2) in my fork and will send you a pull request, for 3) I haven't found a good way to put this logic into deadbolt itself.

For 2) there is an example in deadbolt-usage (java)

Kind regards
Jan