There was an error while loading. Please reload this page.
This feature is available since 0.10
You can use asynchronous libraries ( for example: ReactiveMongo, ScalikeJDBC-Async, and so on ) for User resolver and Authorizer.
trait AuthConfigImpl extends AuthConfig { ...snip def resolveUser(id: Id): Option[User] = throw new AssertionError("dont use!") override def resolveUserAsync(id: Id)(implicit context: ExecutionContext): Future[Option[User]] = AsyncDB.withPool { implicit s => User.findById(id) } }
That's it. No big deal.
AuthElement trait use the resolveUserAsync method always.
AuthElement
resolveUserAsync
If you use old style ( that Auth trait was used ), you can use AsyncAuth instead of Auth.
Auth
AsyncAuth
trait Messages extends Controller with AsyncAuth with AuthConfigImpl { import scala.concurrent.ExecutionContext.Implicits.global def main = authorizedAction(NormalUser) { user => request => val title = "message main" Ok(html.message.main(title)) } def list = authorizedAction(NormalUser) { user => request => val title = "all messages" Ok(html.message.list(title)) } }