Pregunta

I'm trying to use Deadbolt2 in a play2 application and i'm stuck with the implementation of getRolesHolder() in my Deadbolt Handler.

In the sample application, there is this example :

public class MyDeadboltHandler extends AbstractDeadboltHandler
{
    public RoleHolder getRoleHolder()
    {
        // in a real application, the user name would probably be
        // in the session following a login process
        return User.findByUserName("steve");
    }
}

My problem is : how can I get the session in getRoleHolder() ?

I've tried to call Context.current().session(); but I've got the following error :
There is no HTTP Context available from here.

Any ideas ?
Thanks

¿Fue útil?

Solución

The seemingly variable availability of the context is starting to get a bit annoying. I'll change the signature of getRoleHolder() to take the context. Check in github in about 10 minutes, and update your Build.scala version of Deadbolt to take 1.1-SNAPSHOT

Otros consejos

With this accessor

Session session = play.mvc.Http.Context .current().session()

More Play1 to Play2 samples at https://github.com/playframework/Play20/wiki/Play-2.0-for-Play-1.x-developers

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top