Commit 4c3ea880 authored by Frauke's avatar Frauke

add extra error handling

parent 5ebc8ed1
......@@ -6,15 +6,20 @@ module.exports = function (app) {
passport.use('jwt-strategy', new CustomStrategy(
function (req, done) {
const cookie = decodeURIComponent(req.headers.cookie)
console.log(cookie)
if (cookie) {
const jwtToken = getCookie(cookie, 'access_token')
jwt.verify(jwtToken, app.get('tokenSecret'), function (err, decoded) {
if (err) {
done(err, false, {message: 'Access denied'})
} else {
done(null, decoded)
}
})
if (app.get('tokenSecret')) {
jwt.verify(jwtToken, app.get('tokenSecret'), function (err, decoded) {
if (err) {
done(err, false, {message: 'Access denied'})
} else {
done(null, decoded)
}
})
} else {
done(null, false, {message: 'Access denied'})
}
} else {
done(null, false, {message: 'Access denied'})
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment