I am using Deadbolt2
for authorization. When i, extends
DeadboltHandler
and override their methods, i am getting following error in eclipse:
implements be.objectify.deadbolt.scala.DeadboltHandler.getSubject
overriding method getSubject in trait DeadboltHandler of type [A](request: play.api.mvc.Request[A])Option[be.objectify.deadbolt.core.models.Subject]; method getSubject has incompatible type
These are compile time errors and produce on getSubject
method, because of its return type. I declare its return type as Future[Option[Subject]]
and when i use Option[Subject]
as a return type, the errors is removed. When i saw example by steve
https://github.com/schaloner/deadbolt-2-scala-examples/blob/master/app/security/MyDeadboltHandler.scala, he used Future[Option[Subject]]
and there is no error in code when i import code in eclipse. When i compile the code using activator clean compile
command there is no compile time error.
CODE:
override def getSubject[A](request: Request[A]): Future[Option[Subject]] = {
println("Method Start getSubject");
if(!request.headers.get("userId").isEmpty){
println("If Method Start getSubject");
val userId = request.headers.get("userId").get;
userDao.findById(BSONObjectID.apply(userId));
}else{
println("Else Method Start getSubject");
Future(Option.empty);
}}
Update
When i am using deadbolt be.objectify" %% "deadbolt-scala" % "2.3.2
dependency version, i got compile time error in eclipse and build run successfully. But when i use be.objectify" %% "deadbolt-scala" % "2.3.3
dependency version i am getting build error also.