2021-04-13 12:56:57 +02:00
|
|
|
const { Cookies } = require("../../constants")
|
|
|
|
|
2021-04-07 12:33:16 +02:00
|
|
|
exports.options = {
|
|
|
|
secretOrKey: process.env.JWT_SECRET,
|
2021-04-13 12:56:57 +02:00
|
|
|
jwtFromRequest: function(ctx) {
|
|
|
|
return ctx.cookies.get(Cookies.Auth)
|
|
|
|
},
|
2021-04-07 12:33:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
exports.authenticate = async function(jwt, done) {
|
|
|
|
try {
|
|
|
|
return done(null, jwt)
|
|
|
|
} catch (err) {
|
|
|
|
return done(new Error("JWT invalid."), false)
|
|
|
|
}
|
|
|
|
}
|