This commit is contained in:
2020-05-03 18:22:51 -04:00
commit 8dc0e946b1
98 changed files with 19301 additions and 0 deletions

17
nodejs/middleware/auth.js Executable file
View File

@ -0,0 +1,17 @@
'use strict';
const {Auth} = require('../models/auth');
async function auth(req, res, next){
try{
let user = await Auth.checkToken({token: req.header('auth-token')});
if(user.username){
req.user = user;
return next();
}
}catch(error){
next(error);
}
}
module.exports = {auth};