Skip to content

Commit

Permalink
Removed passport from middleware, because auth is handled in other mi…
Browse files Browse the repository at this point in the history
…croservice
  • Loading branch information
ajhool committed Apr 3, 2017
1 parent f261e66 commit 3998e46
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 36 deletions.
12 changes: 6 additions & 6 deletions app/middleware/authenticate.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ export default function authenticate(req, res, next) {
if(user){
req.currentUser = user
next()
} else {
res.status(401).send()
}
} else {
const err = {status: 500}
next(err)
}
})
.catch(function (err) {
// API call failed...
res.status(500).send({message: unable to process request})
err.status = 500
next(err)
})
})
}
30 changes: 0 additions & 30 deletions app/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,6 @@ import helmet from 'helmet'
import routes from './routes'
import Constants from './config/constants'

import passport from 'passport'
import Auth0Strategy from 'passport-auth0'

/*
* Configure Passport to use Auth0 strategy
*/

const strategy = new Auth0Strategy({
domain: process.env.AUTH0_DOMAIN,
clientID: process.env.AUTH0_CLIENT_ID,
clientSecret: process.env.AUTH0_CLIENT_SECRET,
callbackURL: process.env.AUTH0_CALLBACK_URL || 'http://localhost:3000/callback'
}, function(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)

// This can be used to keep a smaller payload
passport.serializeUser(function(user, done) {
done(null, user)
})

passport.deserializeUser(function(user, done) {
done(null, user);
})

const app = express()

//Configure authentication middleware
Expand Down

0 comments on commit 3998e46

Please sign in to comment.