feat: Adding loads and load-attachments endpoints

This commit is contained in:
2023-10-06 20:01:04 -06:00
parent 0b37ea1ac1
commit d019017600
11 changed files with 257 additions and 12 deletions

View File

@@ -7,11 +7,15 @@ const jwtSecret = apiConfig.authentication.jwtSecret;
function middleware( req, res, next ){
if( req.JWT ){
req.JWT.isValid = false;
req.JWT.payload = jwt.verify( req.JWT.raw, jwtSecret );
if( !req.JWT.payload ){
try{
req.JWT.payload = jwt.verify( req.JWT.raw, jwtSecret );
if( !req.JWT.payload ){
return res.status(401).send({error:"Unauthorized",code:401});
}else{
req.JWT.isValid = true;
}
}catch( err ){
return res.status(401).send({error:"Unauthorized",code:401});
}else{
req.JWT.isValid = true;
}
next();
}else{