vendredi 29 juillet 2016

Is it possible to use PassportJS without a local database?

I have an app that uses all of the oAuth authentications that are bundled with passport, but I'm using an external service for my database / user creation.

If I do something like this:

passport.use('local-signup', new LocalStrategy({
        usernameField : 'email',
        passwordField : 'password',
        passReqToCallback : true        },
    function(req, username, password, done) {

        request.post('http://myapiservice.com/createuser').then(function(err,  response, body){
          return done(err, body.user); 
       })

    }))

How would I use a remotely-stored user with this? I'm not connecting to the database in any way other than a POST API call to create the user and a GET call to retrieve the user, so I'm not sure how Express' req.user would behave / get updated.

Can't find a single guide or question about this elsewhere so would love a bit of guidance!

Aucun commentaire:

Enregistrer un commentaire