Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- passport.use(new LocalStrategy(
- function(username, password, done) {
- console.log(username + "----" + password)
- if(username == "test" && password == "test"){
- console.log("SUCCESS")
- done(null, { name: username})
- }
- else{
- done(null, false)
- }
- }))
- .. some othe initialization, cookieparser, bodyparser, session ...
- app.use(passport.initialize())
- app.use(passport.session())
- app.use('/login', login);
- app.post('/login',passport.authenticate('local', { failureRedirect: '/login' }),
- function(req, res) {
- res.redirect('/plans');
- });
- app.all('*',function (req, res, next) {
- console.log(req.isAuthenticated())
- if (req.isAuthenticated()) {
- return next()
- }
- res.redirect('/login')
- })
- app.use('/', index);
- app.use('/users', users);
- app.use('/plans', plans);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement