使用deadbolt2我有以下控制器功能实现:
def restricted: Action = deadbolt.Restrict(List(Array(USER_ROLE)))() { request =>
Future {
val localUser = userProvider.getUser(request.session) // <<< expects a play.mvc.Http.Session
Ok(views.html.restricted(userProvider, localUser))
}
}
但它会导致以下编译器错误:
[error] /home/bravegag/code/play-authenticate-usage-scala/app/controllers/Application.scala:26: type mismatch;
[error] found : play.api.mvc.Session
[error] required: play.mvc.Http.Session
[error] val localUser = userProvider.getUser(request.session)
[error] ^
基本上,电流request
给了我 aplay.api.mvc.Session
但我依赖的库(play-authenticate)期待 a play.mvc.Http.Session
。有没有办法在两者之间转换?还是另一种获取所需Http的方法?