猫鼬用护照js加密的问题?

时间:2019-12-09 02:44:51

标签: encryption passport.js

我试图在我的应用程序中进行猫鼬加密,但出现此错误。而且我现在无法登录我的应用程序。 我应该怎么做才能解决这个问题。谢谢!

我的User.js

const mongoose= require('mongoose');
const passport= require('passport');
const plm=require('passport-local-mongoose');
const encrypt =require('mongoose-encryption') ;
const findOrCreate = require('mongoose-findorcreate');

const UserSchema= new mongoose.Schema(({
    phone:                 String,
    resetPasswordToken:    String,
    resetPasswordExpires:  Date
}));

UserSchema.plugin(plm);
UserSchema.plugin(findOrCreate);
var secret='code secret';


UserSchema.plugin(encrypt.migrations, { requireAuthenticationCode: false,secret:secret });
User = mongoose.model('User', UserSchema);
User.migrateToA(function(err){
    if (err){ throw err; }
    console.log('Migration successful');
});
module.exports = User;

还有我的登录路由器

router.post('/', passport.authenticate('local', {
    successRedirect: '/dashboard',
    failureRedirect: '/',
    failureMessage: 'Invalid Login'
}));

为什么我遇到此错误

cb is not a function
TypeError: cb is not a function
    at model.schema.methods.authenticate (C:\Users\ass\Documents\GitHub\esc\node_modules\mongoose-encryption\lib\plugins\mongoose-encryption.js:413:9)
    at Promise.resolve.then.then (C:\Users\ass\Documents\GitHub\esc\node_modules\passport-local-mongoose\index.js:194:23)
    at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)

0 个答案:

没有答案