This commit is contained in:
2021-01-16 23:55:27 -05:00
commit 10d10079aa
8070 changed files with 386150 additions and 0 deletions

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

@ -0,0 +1,18 @@
'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.uid){
req.user = user;
return next();
}
}catch(error){
next(error);
}
}
module.exports = {auth};