Testing cookies

This commit is contained in:
2022-07-25 15:55:58 +01:00
parent 76fdbc0d13
commit 678d55779d
12 changed files with 79 additions and 148 deletions
@@ -0,0 +1,22 @@
const jwt = require('jsonwebtoken');
const { tokens } = require('../database/models');
//generates a JWT token based on the given arguments
module.exports = (index, email, username, type, admin, mod) => {
const content = {
index,
email,
username,
type,
admin,
mod,
};
//these are strings
const accessToken = jwt.sign(content, process.env.SECRET_ACCESS, { expiresIn: '1s', issuer: 'auth' });
const refreshToken = jwt.sign(content, process.env.SECRET_REFRESH, { expiresIn: '30d', issuer: 'auth' });
tokens.create({ token: refreshToken, email: email });
return { accessToken, refreshToken };
};