Files
sapper-template/app/auth/validate.js
2018-09-24 19:58:30 -06:00

15 lines
316 B
JavaScript

import jwt from 'jsonwebtoken'
const JWT_SECRET = 'put-your-JWT-secret-here'; // you can set this w/ an environment variable
export const authValidate = function(req) {
try {
return jwt.verify(req.cookies.ds, JWT_SECRET)
} catch (error) {
return {
unauthorized: true,
message: 'Unauthorized',
}
}
}