Removed unused authentication and product code

This commit is contained in:
Riccardo
2022-07-15 23:12:37 +02:00
parent 36a945e175
commit 0ee1ce6fb8
14 changed files with 9 additions and 555 deletions

View File

@@ -1,30 +1,5 @@
import jwt from 'jsonwebtoken';
const APP_SECRET = 'GraphQL-is-aw3some';
function getTokenPayload(token) {
return jwt.verify(token, APP_SECRET);
}
function getUserId(req, authToken) {
if (req) {
const authHeader = req.headers.authorization;
if (authHeader) {
const token = authHeader.replace('Bearer ', '');
if (!token) {
throw new Error('No token found');
}
const { userId } = getTokenPayload(token);
return userId;
}
} else if (authToken) {
const { userId } = getTokenPayload(authToken);
return userId;
}
throw new Error('Not authenticated');
}
module.exports = {
APP_SECRET,
getUserId
APP_SECRET
};