I'm surprised that it's so hard to find, or maybe something wrong with me.
I need a passport.js
strategy
that requires no fields - to run authentication with it on simple user GET
request to '/'
and manipulate user session data to, for example, make a new 'guest' user.
Maybe i can do this via passport local-strategy
? Or am i need to create a custom one?
I saw this Configure Passport to accept request without body? question, yet i just simply can't figure out how the suggested in answer wrapping will change anything.
Edit: here's what I'm trying to achieve
passport.use('guest', new LocalStrategy({
passReqToCallback: true
},
function (req, NOusername, NOpassword, done) {
////NO PASSWORD OR USERNAME checks here, just deciding what kind of temporary user needs to be created///
if (req.session.passport) {
///create new user with previous session data
done(null,user)
}
else {
///create clean user
done(null, user)
})
)
and then in routes.js
app.get('/', passport.authenticate('guest'), function (req, res) {
res.render('PeerRoom.ejs', req.user);
});
Edit: Another approach could be using
req.logIn
and skip dealing with the strategies altogetherTo make a new guest user, simply do it instead of rejecting an authentication
Here's a modified example from the docs