2

I have my custom authenticated action that is like

def Authenticated(rights: String*) = new ActionBuilder[MyAuthenticatedRequest] {
  ***
}

In my controller I use this action to check the user has the right to view the page

def password = Authenticated(UserRights.USER) { implicit request: MyAuthenticatedRequest[_] =>
  Users.findById(request.account.id) match {
    case Some(user) => Ok(views.html.settings.password(frontUser, user))
    case _ => NotFound
  }
}

My oject Users uses slick to retrieve the user in the database

def findById(id: Long)(implicit s: Session): Option[User] = users.where(_.id === id).firstOption

In my controller I have an error

could not find implicit value for parameter s: play.api.db.slick.Config.driver.simple.Session

This is due to the fact that I have to open a session in my controller before querying the database.

I would like to use DBAction that is provided by play-slick and compose it with my authenticated action but I have some problems understanding how action composition works

cvogt
  • 11,260
  • 30
  • 46
Seb Cesbron
  • 3,823
  • 15
  • 18
  • any news on this - did you resolve the issue? I'd want to achieve the exact same thing and need to use DBAction because that resolves my other issue http://stackoverflow.com/questions/22622892/play-slick-session-connection-timeout?noredirect=1 – mattanja Apr 04 '14 at 22:54
  • FYI, there are also these tweets about it: https://twitter.com/mattanja/status/452428607731040256 https://twitter.com/gbougeard/status/452532062533480448 – cvogt Apr 05 '14 at 22:59
  • FYI - I gave up on this side-project and didn't further follow the issue. If you have the same problem you may check out the tweets linked by @cvogt or report to the play-slick project I guess. – mattanja Jul 17 '14 at 07:36
  • This PR seems to request and suggest a solution to this https://github.com/playframework/play-slick/issues/84 – cvogt Jul 17 '14 at 07:57

0 Answers0