我有一个返回Future Option的DAO方法,它是这样的:
def authenticate(username: String, password: String): Future[Option[User]] = {
val query = db.run(Users.filter(x => x.email === username && password.isBcrypted(x.password.toString())).result).map(_.headOption)
query
}
问题是,password.isBcrypted(x.password.toString()),我试图获取x.password的值,但它是Rep [String],我试图找到如何从中获取值Rep [T]但无法提出解决方案。
这有什么好方法吗?
val query = db.run(Users.filter(_.email === username).result.map(_.headOption.filter(user => password.isBcrypted(user.password)))).map(_.headOption)
答案 0 :(得分:2)
获取result
后可以检查密码:
Users.filter(_.email === username).result.map(_.headOption.filter(user => password.isBcrypted(user.password)))