Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const getUser = headers => {
const authorization = headers.authorization || headers.Authorization;
if (!authorization) {
throw new AuthenticationError('Missing authorization header');
}
const token = authorization.replace('Bearer ', '');
try {
return jwt.verify(token, process.env.APP_SECRET);
} catch (error) {
throw new AuthenticationError(error.message);
}
};
const getUser = headers => {
const authorization = headers.authorization || headers.Authorization;
if (!authorization) {
throw new AuthenticationError('Missing authorization header');
}
const token = authorization.replace('Bearer ', '');
try {
return jwt.verify(token, process.env.APP_SECRET);
} catch (error) {
throw new AuthenticationError(error.message);
}
};