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