小编Amm*_*ayg的帖子

Mongoose bcryptjs 比较密码不参考文档(this)

我有这样的猫鼬模式

var mongoose  = require ('mongoose');
var bcrypt = require('bcryptjs');
var Schema = mongoose.Schema;
var SALT_WORK_FACTOR = 10;
var touristSchema = new Schema ({
    local: {
        email: String,
        password: String
    },
    facebook: {
        id: String,
        token: String,
        email: String,
        name: String,
    }
});


touristSchema.pre('save', function(next) {
    var user = this;
    console.log('bcrypt called by strategy', user);

// if user is facebook user skip the pasword thing.
if (user.facebook.token) {
    next();
}
// only hash the password if it has been modified …
Run Code Online (Sandbox Code Playgroud)

mongodb node.js passport.js mongoose-schema

5
推荐指数
0
解决办法
556
查看次数

标签 统计

mongodb ×1

mongoose-schema ×1

node.js ×1

passport.js ×1