Files
frontend/middleware/passport.js
T
2018-09-13 21:15:47 +02:00

29 lines
860 B
JavaScript

const Auth0Strategy = require("passport-auth0")
const passport = require("passport")
const config = require("../config")
//passport-auth0
const strategy = new Auth0Strategy({
domain: config.auth0.domain,
clientID: config.auth0.clientId,
clientSecret: config.auth0.secret, // Replace this with the client secret for your app
callbackURL: config.root + "/auth/callback"
}, (accessToken, refreshToken, extraParams, profile, done) => {
// accessToken is the token to call Auth0 API (not needed in the most cases)
// extraParams.id_token has the JSON Web Token
// profile has all the information from the user
return done(null, profile);
}
)
passport.use(strategy)
passport.serializeUser(function(user, done) {
done(null, user);
});
passport.deserializeUser(function(user, done) {
done(null, user);
});
module.exports = passport