mirror of
https://github.com/kevin-DL/sapper-template.git
synced 2026-01-15 11:34:45 +00:00
Work on login
This commit is contained in:
14
app/auth/validate.js
Normal file
14
app/auth/validate.js
Normal file
@@ -0,0 +1,14 @@
|
||||
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',
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user