mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
* lint @typescript-eslint/recommended * lint @typescript-eslint/recommended-requiring-type-checking fix type not detected locally due to wierd uuid typings missing save error not reported locally --------- Co-authored-by: Wolfgang Huß <wolle.huss@pjannto.com>
20 lines
649 B
TypeScript
20 lines
649 B
TypeScript
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
import jwt from 'jsonwebtoken'
|
|
|
|
import CONFIG from '@config/index'
|
|
|
|
// Generate an Access Token for the given User ID
|
|
export default function encode(user) {
|
|
const { id, name, slug } = user
|
|
const token = jwt.sign({ id, name, slug }, CONFIG.JWT_SECRET, {
|
|
expiresIn: CONFIG.JWT_EXPIRES,
|
|
issuer: CONFIG.GRAPHQL_URI,
|
|
audience: CONFIG.CLIENT_URI,
|
|
subject: user.id.toString(),
|
|
})
|
|
return token
|
|
}
|