catch invalid signature

This commit is contained in:
leca 2025-02-07 00:12:31 +03:00
parent 91d6e64f18
commit 46c475593b
2 changed files with 11 additions and 7 deletions

View File

@ -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 = {

View File

@ -7,6 +7,7 @@ import UserService from '../services/user.js';
dotenv.config({path: ".env"});
const authenticate = async (req, res, next) => {
try {
const token = req.cookies["jwt"];
if (!token || !jwt.verify(token, process.env.SECRET)) {
req.session.destroy();
@ -14,6 +15,9 @@ const authenticate = async (req, res, next) => {
return res.redirect("/login");
}
next();
} catch(e) {
console.log(e)
}
};
const validateInviteToken = async (req, res, next) => {