Finished AuthContext

This commit is contained in:
Cassio Santos
2020-06-15 10:25:52 -03:00
parent 0b75b4aa52
commit eaea17fb66
20 changed files with 375 additions and 1149 deletions

View File

@@ -3,7 +3,7 @@ const jwt = require("jsonwebtoken");
module.exports = (req, res, next) => {
let decodedToken;
try {
const token = req.get("Authorization").split(" ")[1];
const [, token] = req.get("Authorization").split(" ");
decodedToken = jwt.verify(token, "mysecret");
} catch (err) {
err.statusCode = 401;