Compare commits
2 Commits
550fa0fbe4
...
ac17b5906e
Author | SHA1 | Date |
---|---|---|
|
ac17b5906e | |
|
46c475593b |
|
@ -7,13 +7,17 @@ import UserService from '../services/user.js';
|
||||||
dotenv.config({path: ".env"});
|
dotenv.config({path: ".env"});
|
||||||
|
|
||||||
const authenticate = async (req, res, next) => {
|
const authenticate = async (req, res, next) => {
|
||||||
const token = req.cookies["jwt"];
|
try {
|
||||||
if (!token || !jwt.verify(token, process.env.SECRET)) {
|
const token = req.cookies["jwt"];
|
||||||
req.session.destroy();
|
if (!token || !jwt.verify(token, process.env.SECRET)) {
|
||||||
res.clearCookie("jwt");
|
req.session.destroy();
|
||||||
return res.redirect("/login");
|
res.clearCookie("jwt");
|
||||||
|
return res.redirect("/login");
|
||||||
|
}
|
||||||
|
next();
|
||||||
|
} catch(e) {
|
||||||
|
console.log(e)
|
||||||
}
|
}
|
||||||
next();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const validateInviteToken = async (req, res, next) => {
|
const validateInviteToken = async (req, res, next) => {
|
||||||
|
|
Loading…
Reference in New Issue