londonappbrewery / Authentication-Secrets

Companion Code for the Authentication Module on The Complete 2019 Web Development Bootcamp
https://www.appbrewery.co
440 stars 524 forks source link

TypeError: User.createStrategy is not a function #21

Closed wolfgang04 closed 2 years ago

wolfgang04 commented 2 years ago

Was just following and encountered this error. Tried searching google for solutions and can't find anything.


app.set("view engine", "ejs");
app.use(bodyParser.urlencoded({extended: true}));

app.use(session({
    secret: "mysecret.",
    resave: false,
    saveUninitialized: false, 
}));

app.use(passport.initialize());
app.use(passport.session());

mongoose.connect("mongodb://localhost:27017/userDB");

const userSchema = new mongoose.Schema({
    email: String,
    password: String
});

const User = new mongoose.model("User", userSchema);

passport.use(User.createStrategy());

passport.serializeUser(User.serializeUser());
passport.deserializeUser(User.deserializeUser());

userSchema.plugin(passportLocalMongoose); ```

this is my code and can't find anything wrong with it
wolfgang04 commented 2 years ago

Seemed to misplace the plugin