I'm doing the following tutorial:
https://www.raymondcamden.com/2017/02/08/using-social-login-with-passport-and-node/
but the code for the file: ./models/user
referenced on the line:
var user = require('./models/user');
is not provided.
Then, I'm getting the error:
Error: Cannot find module './models/user'
The variable: user
is used on the following lines:
var me = new user({
email:profile.emails[0].value,
name:profile.displayName
});
/* save if new */
user.findOne({email:me.email}, function(err, u) {
if(!u) {
me.save(function(err, me) {
if(err) return done(err);
done(null,me);
});
} else {
console.log(u);
done(null, u);
}
});
But I have no idea about what should be the content of the file: ./models/user
.
Could you provide me some test content that makes this tutorial work?
Use this code on models/user file.
Just check it.
var mongoose=require("mongoose");
var passportlocalmongoose=require("passport-local-mongoose");
var UserSchema=mongoose.Schema({
email: String,
Password: String
});
UserSchema.plugin(passportlocalmongoose);
module.exports=mongoose.model("User", UserSchema);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.