2
votes

I am trying to use the security helpers inside a controller as shown in the source code of Security.scala

https://github.com/playframework/playframework/blob/2.3.x/framework/src/play/src/main/scala/play/api/mvc/Security.scala#L31

My code looks like

import play.mvc.Security.Authenticated

Application extends Controller {
  ..... some other Actions
  def isAuthenticated(f: => String => Request[AnyContent] => Result) = {
      Authenticated { user =>
          Action(request => f(user)(request))
        }
    }
}

However, I am getting the following compilation error

[info] Compiling 1 Scala source to /home/venki/play/lrs/target/scala-2.11/classes...
[error] /home/venki/play/lrs/app/controllers/Application.scala:119: object play.mvc.Security.Authenticated is not a value
[error]       Authenticated { user =>
[error]       ^
[error] one error found
[error] (compile:compile) Compilation failed

I can't understand the error. From the source code i can see that Security object contains two overloaded methods named Authenticated. I have exactly copy pasted the code given as example usage, still it does not work. Any help is very much appreciated

1

1 Answers

6
votes

The Security type you are refering to on github lies in the play.api.mvc package but you are importing the one from the play.mvc. play.mvc is reserved for Java, not for Scala, see here for more info.