catch invalid signature
This commit is contained in:
parent
91d6e64f18
commit
46c475593b
|
@ -59,7 +59,7 @@ $(document).ready(async () => {
|
|||
|
||||
const sendData = async () => {
|
||||
const jwt = getCookie("jwt");
|
||||
const author = await fetch(`/api/getUsername`)
|
||||
const author = (await fetch(`/api/getUsername`)).text()
|
||||
const content = $("#chat-input").val();
|
||||
|
||||
const message = {
|
||||
|
|
|
@ -7,13 +7,17 @@ import UserService from '../services/user.js';
|
|||
dotenv.config({path: ".env"});
|
||||
|
||||
const authenticate = async (req, res, next) => {
|
||||
const token = req.cookies["jwt"];
|
||||
if (!token || !jwt.verify(token, process.env.SECRET)) {
|
||||
req.session.destroy();
|
||||
res.clearCookie("jwt");
|
||||
return res.redirect("/login");
|
||||
try {
|
||||
const token = req.cookies["jwt"];
|
||||
if (!token || !jwt.verify(token, process.env.SECRET)) {
|
||||
req.session.destroy();
|
||||
res.clearCookie("jwt");
|
||||
return res.redirect("/login");
|
||||
}
|
||||
next();
|
||||
} catch(e) {
|
||||
console.log(e)
|
||||
}
|
||||
next();
|
||||
};
|
||||
|
||||
const validateInviteToken = async (req, res, next) => {
|
||||
|
|
Loading…
Reference in New Issue