My codebase contains the following:
// Documentation: http://silhouette.mohiva.com/docs/authorization
case object Admin extends Authorization[User, CookieAuthenticator] {
def isAuthorized[B](user: User, authenticator: CookieAuthenticator)(
implicit request: Request[B]) = {
Future.successful(user.isAdmin)
}
}
val AdminAction = silhouette.SecuredAction(Admin)
val MemberAction = silhouette.SecuredAction
The compilation fails with the following error message:
[error] /home/laing/my/scala-server/app/controllers/Application.scala:553: overloaded method value apply with alternatives:
[error] (authorization: com.mohiva.play.silhouette.api.Authorization[utils.auth.DefaultEnv#I,utils.auth.DefaultEnv#A])com.mohiva.play.silhouette.api.actions.SecuredActionBuilder[utils.auth.DefaultEnv] <and>
[error] (errorHandler: com.mohiva.play.silhouette.api.actions.SecuredErrorHandler)com.mohiva.play.silhouette.api.actions.SecuredActionBuilder[utils.auth.DefaultEnv] <and>
[error] (block: => play.api.mvc.Result)play.api.mvc.Action[play.api.mvc.AnyContent] <and>
[error] (block: com.mohiva.play.silhouette.api.actions.SecuredRequest[utils.auth.DefaultEnv,play.api.mvc.AnyContent] => play.api.mvc.Result)play.api.mvc.Action[play.api.mvc.AnyContent] <and>
[error] [A](bodyParser: play.api.mvc.BodyParser[A])(block: com.mohiva.play.silhouette.api.actions.SecuredRequest[utils.auth.DefaultEnv,A] => play.api.mvc.Result)play.api.mvc.Action[A]
[error] cannot be applied to (Application.this.Admin.type)
[error] val AdminAction = silhouette.SecuredAction(Admin)
[error] ^
[error] one error found
[error] (compile:compileIncremental) Compilation failed
When I change the case object to a case class with a dummy argument, I get almost the same error message (it just says the type is Application.this.Admin instead of Application.this.Admin.type). How do I make the compiler see Admin as an Authorization type?
Thanks
Ambrose