我有一个DAO方法,它返回一个Future Option,就像这样:
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)
您可以在获取以下内容后检查密码result
:
Users.filter(_.email === username).result.map(_.headOption.filter(user => password.isBcrypted(user.password)))
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句