mirror of
https://github.com/kevin-DL/sapper-template.git
synced 2026-01-12 02:15:17 +00:00
15 lines
316 B
JavaScript
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',
|
|
}
|
|
}
|
|
}
|