From 5fe8ea1b85299564686f3fba331644e1178f363e Mon Sep 17 00:00:00 2001 From: Tyler Murphy Date: Sun, 22 Jan 2023 20:47:39 -0500 Subject: [PATCH] bug fixes --- public/404.html | 6 +++--- public/home.html | 14 +++++++------- public/js/api.js | 2 +- public/js/home.js | 11 +++++++++++ public/login.html | 8 ++++---- public/people.html | 14 +++++++------- public/profile.html | 18 +++++++++--------- src/api.js | 4 ++-- 8 files changed, 44 insertions(+), 33 deletions(-) diff --git a/public/404.html b/public/404.html index 49f0d5d..04ddadc 100644 --- a/public/404.html +++ b/public/404.html @@ -2,9 +2,9 @@ - - - + + + XSSBook - Not Found diff --git a/public/home.html b/public/home.html index cc780ac..79c807b 100644 --- a/public/home.html +++ b/public/home.html @@ -2,16 +2,16 @@ - - - + + + XSSBook - Home - - - - + + + + \ No newline at end of file diff --git a/public/js/api.js b/public/js/api.js index 371ecf3..05a0906 100644 --- a/public/js/api.js +++ b/public/js/api.js @@ -1,4 +1,4 @@ -const endpoint = 'https://xssbook.com/api' +const endpoint = 'https://xssbook.com' const request = async (url, body, method) => { if (method === undefined) method = 'POST' diff --git a/public/js/home.js b/public/js/home.js index e0186a8..7697c29 100644 --- a/public/js/home.js +++ b/public/js/home.js @@ -7,6 +7,9 @@ function parseDate(date) { function parseComment(comment) { const author = data.users[comment.user] + if (author === undefined) { + author = {} + } const html = `
@@ -23,6 +26,9 @@ function parseComment(comment) { function parsePost(post) { const author = data.users[post.user] + if (author === undefined) { + author = {} + } const html = `
@@ -189,6 +195,11 @@ async function load() { data.posts.push(... posts) const batch = [] for (const post of posts) { + for(const comment of post.comments) { + if (data.users[comment.user] !== undefined) continue + if (batch.includes(comment.user)) continue + batch.push(comment.user) + } if (data.users[post.user] !== undefined) continue if (batch.includes(post.user)) continue batch.push(post.user) diff --git a/public/login.html b/public/login.html index 538d248..50b4724 100644 --- a/public/login.html +++ b/public/login.html @@ -2,10 +2,10 @@ - - - - + + + + XSSBook - Login diff --git a/public/people.html b/public/people.html index f0aa514..399751a 100644 --- a/public/people.html +++ b/public/people.html @@ -2,14 +2,14 @@ - - - + + + XSSBook - People - - - - + + + + \ No newline at end of file diff --git a/public/profile.html b/public/profile.html index 0274327..d17ab09 100644 --- a/public/profile.html +++ b/public/profile.html @@ -2,16 +2,16 @@ - - - - + + + + XSSBook - Profile - - - - - + + + + + \ No newline at end of file diff --git a/src/api.js b/src/api.js index 3e4cb4d..01edfc6 100644 --- a/src/api.js +++ b/src/api.js @@ -59,7 +59,7 @@ router.post('/auth/register', (req, res) => { if (key === undefined) { res.status(500).send( {msg: 'Failed to register user'} ); return; } - res.status(200).cookie('auth', key).send({msg: 'Successfully registered new user'}) + res.status(200).cookie('auth', key, { maxAge: 365 * 24 * 60 * 60 * 1000, sameSite: 'strict' }).send({msg: 'Successfully registered new user'}) }) router.post('/auth/login', (req, res) => { @@ -75,7 +75,7 @@ router.post('/auth/login', (req, res) => { if (key === undefined) { res.status(400).send( {msg: 'Invalid login combination'} ); return; } - res.status(200).cookie('auth', key).send({msg: 'Successfully logged in'}) + res.status(200).cookie('auth', key, { maxAge: 365 * 24 * 60 * 60 * 1000, sameSite: 'strict' }).send({msg: 'Successfully logged in'}) }) router.post('/auth/self', (req, res) => {