mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
This won't fix the bug that can happen in `nuxtServerInit`. However, according to the docs, we accepted JWT which was valid for 1000 days and our cookie was valid for 3 days - completely weird. See: https://github.com/auth0/node-jsonwebtoken https://github.com/nuxt-community/apollo-module
17 lines
476 B
JavaScript
17 lines
476 B
JavaScript
import jwt from 'jsonwebtoken'
|
|
import CONFIG from './../config'
|
|
|
|
// Generate an Access Token for the given User ID
|
|
export default function encode(user) {
|
|
const token = jwt.sign(user, CONFIG.JWT_SECRET, {
|
|
expiresIn: '1d',
|
|
issuer: CONFIG.GRAPHQL_URI,
|
|
audience: CONFIG.CLIENT_URI,
|
|
subject: user.id.toString(),
|
|
})
|
|
// jwt.verifySignature(token, CONFIG.JWT_SECRET, (err, data) => {
|
|
// console.log('token verification:', err, data)
|
|
// })
|
|
return token
|
|
}
|