catch invalid signature
This commit is contained in:
		@@ -59,7 +59,7 @@ $(document).ready(async () => {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    const sendData = async () => {
 | 
					    const sendData = async () => {
 | 
				
			||||||
        const jwt = getCookie("jwt");
 | 
					        const jwt = getCookie("jwt");
 | 
				
			||||||
        const author = await fetch(`/api/getUsername`)
 | 
					        const author = (await fetch(`/api/getUsername`)).text()
 | 
				
			||||||
        const content = $("#chat-input").val();
 | 
					        const content = $("#chat-input").val();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        const message = {
 | 
					        const message = {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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) => {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user