Colt / YelpCamp

583 stars 560 forks source link

Simplified Passport/Passport-Local Configuration #46

Open FCimendere opened 6 months ago

FCimendere commented 6 months ago

Hello @Colt

For the app.js file while we are using authentication over passport there is an update.

Starting from version 0.2.1, passport-local-mongoose adds a helper method createStrategy as static method to your schema. The createStrategy is responsible to setup passport-local LocalStrategy with the correct options. Bacuse of this no need to define LocalStrategy and using this lines of code : passport.use(new LocalStrategy(User.authenticate()));

We could update this lines as below:

const User = require('./models/user');

// CHANGE: USE "createStrategy" INSTEAD OF "authenticate" passport.use(User.createStrategy());