aboutsummaryrefslogtreecommitdiffstats
path: root/passport.js
diff options
context:
space:
mode:
Diffstat (limited to 'passport.js')
-rw-r--r--passport.js9
1 files changed, 7 insertions, 2 deletions
diff --git a/passport.js b/passport.js
index ac34178f..7456532a 100644
--- a/passport.js
+++ b/passport.js
@@ -3,16 +3,19 @@ import jwt from 'passport-jwt'
import dotenv from 'dotenv'
dotenv.config()
+const l = console.log
+
function cookieExtractor (req) {
if (req && req.cookies) return req.cookies['token']
return null
}
module.exports = (db) => {
- passport.use(new jwt.Strategy({
+ passport.use(
+ new jwt.Strategy({
jwtFromRequest: jwt.ExtractJwt.fromExtractors([cookieExtractor]),
secretOrKey: process.env.SECRET
- }, async function (payload, next) {
+ }, async (payload, next) => {
try {
let user = await db.User.findOne({
where: {
@@ -21,6 +24,7 @@ module.exports = (db) => {
})
next(null, user)
} catch(err) {
+ l(err)
next(null, false)
}
})
@@ -29,3 +33,4 @@ module.exports = (db) => {
return passport
}
+