Я пишу приложение Play 2.3, используя SecureSocial (основная версия). Я создал LoginUser, который представляет данные пользователя в моей системе.
/**
* Class representing a User in the system.
* @constructor Create a new LoginUser instance from a BasicProfile object.
* @param profile represents the BasicProfile object associated with the user.
*/
case class LoginUser(val profile: BasicProfile)
Теперь я пытаюсь реализовать черту UserService[T] (из SecureSocial), но у меня проблемы.
/**
* Class tha handle all the request for read/write user data in/from the database.
*/
class InMemoryUserService extends UserService[LoginUser] {
private var tokens = Map[String, MailToken]()
/**
* Finds a user by provider id and user id.
* @param providerId - the user provider id.
* @param userId - the user user id.
* @return an optional user
*/
def find(providerId: String, userId: String): Future[Option[BasicProfile]] = {
val future: Future[Option[LoginUser]] = UserServiceLogin.find(Json.obj("providerId" -> providerId, "userId" -> userId)).one
future onComplete {
case Success(Some(x)) => return x.profile
case _ => None
}
}
Метод find возвращает объект Future[Option[BasicProfile]], но компилятор говорит мне, что код неверен. Вот вывод компилятора:
[error] /Users/alberto/git/recommendation-system/app/security/UserService.scala:68: type mismatch;
[error] found : securesocial.core.BasicProfile
[error] required: scala.concurrent.Future[Option[securesocial.core.BasicProfile]]
[error] case Success(Some(x)) => return x.profile
Что случилось?? Как мне решить мою проблему??