mirror of
https://github.com/cheveguerra/whaticket-community.git
synced 2026-04-18 11:49:19 +00:00
Start using sequelize migrations
This commit is contained in:
@@ -1,17 +1,13 @@
|
||||
const jwt = require("jsonwebtoken");
|
||||
const authConfig = require("../config/auth");
|
||||
|
||||
module.exports = (req, res, next) => {
|
||||
let decodedToken;
|
||||
try {
|
||||
const [, token] = req.get("Authorization").split(" ");
|
||||
decodedToken = jwt.verify(token, "mysecret");
|
||||
// todo >> find user in DB and store in req.user to use latter, or throw an error if user not exists anymore
|
||||
req.userId = decodedToken.userId;
|
||||
} catch (err) {
|
||||
err.statusCode = 401;
|
||||
err.message = "invalidToken";
|
||||
next(err);
|
||||
}
|
||||
|
||||
const [, token] = req.get("Authorization").split(" ");
|
||||
decodedToken = jwt.verify(token, authConfig.secret);
|
||||
// todo >> find user in DB and store in req.user to use latter, or throw an error if user not exists anymore
|
||||
req.userId = decodedToken.userId;
|
||||
|
||||
if (!decodedToken) {
|
||||
return res.status(401).json({ message: "Unauthorized" });
|
||||
|
||||
Reference in New Issue
Block a user