diff --git a/README.md b/README.md index fad3a2b..bca1e41 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,6 @@ Read the [configuation guide](docs/CONFIG.md) for configuration help (in config. * probably insecure as hell # Planned features/todo list -* URGENT give each post and user a hard postID to prevent potential issues * edit user (could be on instead of the delete_account page) * user specific RSS feeds * atom diff --git a/src/server.js b/src/server.js index 72c0b59..b91b9fa 100644 --- a/src/server.js +++ b/src/server.js @@ -306,18 +306,18 @@ app.post("/submit_delete_account", (req,res) => { if (password == users[userID]['hash']) { // password matches console.log(username, "(userID:", userID, ") is trying deleting their account") // Delete the user - users.splice(userID,1) + users[userID] = {"deleted": true} // Delete all their posts for (let postid = 0; postid < posts.length; postid++) { // loop over all posts if (posts[postid]['userID'] == userID) { // if userID matches - posts.splice(postid,1) // delete the post - comments.comments.splice(postid,1) // the comments for this post should also be delete + posts[postid] = {"deleted": true} // delete the post + comments.comments[postid] = {"deleted": true} // the comments for this post should also be deleted } }; // Write these changes fs.writeFileSync(`../data/users.json`, `${JSON.stringify(users)}`, 'utf-8'); fs.writeFileSync(`../data/posts.json`, `${JSON.stringify(posts)}`, 'utf-8'); - fs.writeFileSync(`../data/comments.json`, `${JSON.stringify(comments.comments)}\nexport const counter = ${comments.counter}`, 'utf-8'); + fs.writeFileSync(`../data/comments.json`, `${JSON.stringify(comments)}`, 'utf-8'); res.redirect(301,"/") } else { // password does not match @@ -354,8 +354,8 @@ app.post("/submit_edit", (req,res) => { post['editdate'] = unix_timestamp if (typeof delete_bool != "undefined") { console.log("Deleting post!") - posts.splice(postID,1) - comments.comments.splice(postID,1) + posts[postID] = {"deleted": true} + comments.comments[postID] = {"deleted": true} fs.writeFileSync(`../data/comments.json`, `${JSON.stringify(comments.comments)}\nexport const counter = ${comments.counter}`, 'utf-8'); } fs.writeFileSync(`../data/posts.json`, `${JSON.stringify(posts)}`, 'utf-8'); diff --git a/views/headers/user.ejs b/views/headers/user.ejs index 949aefc..cdc6f55 100644 --- a/views/headers/user.ejs +++ b/views/headers/user.ejs @@ -1,4 +1,5 @@
<%- converter.makeHtml(user.description) %>
<%- config.seperator %> diff --git a/views/pages/timeline.ejs b/views/pages/timeline.ejs index 4df5505..24034f0 100644 --- a/views/pages/timeline.ejs +++ b/views/pages/timeline.ejs @@ -9,7 +9,9 @@