mirror of
https://github.com/EQEmu/Server.git
synced 2026-09-02 00:06:36 +00:00
WebInterface reference implementation
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
const jwt = require('jsonwebtoken');
|
||||
|
||||
var Auth = function (req, res, next) {
|
||||
var token = '';
|
||||
try {
|
||||
token = req.headers.authorization.substring(7);
|
||||
} catch(ex) {
|
||||
console.log(ex);
|
||||
res.sendStatus(401);
|
||||
return;
|
||||
}
|
||||
|
||||
jwt.verify(token, req.key, function(err, decoded) {
|
||||
if(err) {
|
||||
console.log(err);
|
||||
res.sendStatus(401);
|
||||
return;
|
||||
}
|
||||
|
||||
req.token = decoded;
|
||||
next();
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
'auth': Auth
|
||||
}
|
||||
Reference in New Issue
Block a user