0

Waterline 支持生命周期回调 ( docs )。我的User模型有:

beforeValidate: hash_password,
beforeCreate: hash_password,
beforeUpdate: hash_password

这适用于创建/更新记录(我在数据库中仔细检查过)。

但是在我身上findOne我总是得到一个NotFoundError

User.findOne({email: req.body.email, password: req.body.password}, (err, user) =>
                 cb(err ? err : !user ? new NotFoundError('User') : null)

打开数据库日志记录,我确认其中的密码findOne永远不会被散列。

我究竟做错了什么?

4

0 回答 0