Made it so if an invalid user or post is loaded, a proper error message is

shown instead of just a nodeJS error message
This commit is contained in:
2025-09-06 23:54:49 +01:00
parent c8af978259
commit e3e5469e1a

View File

@@ -191,7 +191,7 @@ app.get("/", (req,res) => {
app.get("/user/:username", (req, res) => {
const userID = func.get_userID(req.params.username)
console.log(userID)
console.log(users[userID].prettyname)
if (userID != -1) {
res.render("pages/user",
{
config,
@@ -205,10 +205,18 @@ app.get("/user/:username", (req, res) => {
getUnixTime: getUnixTime,
func,
})
}
else if (userID == -1) {
res.render("partials/message",
{
message: locale.user_doesnt_exist,
config,
})
}
}); // /user/:username
app.get("/post/:post_index", (req, res) => {
const postID = req.params.post_index
if (posts[postID]["deleted"] == true) {
if (postID > posts.length-1 || posts[postID]["deleted"] == true) {
res.render("partials/message", {
message: locale.post_doesnt_exist,
config,