summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--server.js60
-rw-r--r--views/account_change_about.pug (renamed from views/change_about.pug)0
-rw-r--r--views/account_change_mail.pug (renamed from views/change_mail.pug)0
-rw-r--r--views/account_change_name.pug (renamed from views/change_name.pug)0
-rw-r--r--views/account_change_password.pug (renamed from views/change_password.pug)0
-rw-r--r--views/account_delete.pug (renamed from views/delete_account.pug)0
-rw-r--r--views/account_forgot_password.pug (renamed from views/forgot_password.pug)0
-rw-r--r--views/account_reset_password.pug (renamed from views/reset_password.pug)0
-rw-r--r--views/account_webhook.pug (renamed from views/webhook.pug)0
-rw-r--r--views/contacts_search.pug (renamed from views/search_user.pug)0
-rw-r--r--views/create_index.pug (renamed from views/create-index.pug)0
-rw-r--r--views/create_title.pug (renamed from views/create.pug)0
-rw-r--r--views/profile.pug4
-rw-r--r--views/stats_title.pug2
-rw-r--r--views/title.pug (renamed from views/info.pug)0
15 files changed, 36 insertions, 30 deletions
diff --git a/server.js b/server.js
index cfaced7..9ba77f2 100644
--- a/server.js
+++ b/server.js
@@ -139,9 +139,11 @@ if (process.env.MAIL_HOST && process.env.MAIL_PORT && process.env.MAIL_FROM) {
console.log("Mail notifications enabled: ", mailer.options)
} else {
console.log("Mail notifications disabled.")
- mailer = {
- sendMail(mail) {
- console.log("MAIL (DEBUG):", mail)
+ if (DEBUG) {
+ mailer = {
+ sendMail(mail) {
+ console.log("MAIL (DEBUG):", mail)
+ }
}
}
}
@@ -541,7 +543,7 @@ app.get("/", function (req, res) {
})
app.get("/create", function (req, res) {
- res.render("create-index.pug")
+ res.render("create_index.pug")
})
app.get("/about", function (req, res) {
@@ -639,7 +641,7 @@ app.post("/account/mail/verify", must_be_logged_in, function (req, res) {
app.get("/account/forgot-password", function (req, res) {
if (req.user)
return res.redirect("/")
- res.render("forgot_password.pug")
+ res.render("account_forgot_password.pug")
})
app.post("/account/forgot-password", must_pass_altcha, function (req, res) {
@@ -650,7 +652,7 @@ app.post("/account/forgot-password", must_pass_altcha, function (req, res) {
mail_password_reset_token(user, token)
return res.redirect("/account/reset-password?mail=" + mail)
}
- res.render("forgot_password.pug", { flash: "User not found." })
+ res.render("account_forgot_password.pug", { flash: "User not found." })
})
app.get("/account/reset-password", function (req, res) {
@@ -658,7 +660,7 @@ app.get("/account/reset-password", function (req, res) {
return res.redirect("/")
var mail = req.query.mail
var token = req.query.token
- res.render("reset_password.pug", { mail, token })
+ res.render("account_reset_password.pug", { mail, token })
})
app.post("/account/reset-password", must_pass_altcha, function (req, res) {
@@ -666,7 +668,7 @@ app.post("/account/reset-password", must_pass_altcha, function (req, res) {
let token = req.body.token
let password = req.body.password
function err(msg) {
- res.render("reset_password.pug", { mail: mail, token: token, flash: msg })
+ res.render("account_reset_password.pug", { mail: mail, token: token, flash: msg })
}
let user = SQL_SELECT_LOGIN_BY_MAIL.get(mail)
if (!user)
@@ -684,7 +686,7 @@ app.post("/account/reset-password", must_pass_altcha, function (req, res) {
})
app.get("/account/change-password", must_be_logged_in, function (req, res) {
- res.render("change_password.pug")
+ res.render("account_change_password.pug")
})
app.post("/account/change-password", must_be_logged_in, function (req, res) {
@@ -693,9 +695,9 @@ app.post("/account/change-password", must_be_logged_in, function (req, res) {
// Get full user record including password and salt
let user = SQL_SELECT_LOGIN.get(req.user.user_id)
if (!is_valid_password(newpass))
- return res.render("change_password.pug", { flash: "New password is invalid!" })
+ return res.render("account_change_password.pug", { flash: "New password is invalid!" })
if (!verify_password(req.user, oldpass))
- return res.render("change_password.pug", { flash: "Wrong password!" })
+ return res.render("account_change_password.pug", { flash: "Wrong password!" })
let salt = crypto.randomBytes(32).toString("hex")
let hash = hash_password(newpass, salt)
SQL_UPDATE_USER_PASSWORD.run(user.user_id, hash, salt)
@@ -717,7 +719,7 @@ function may_delete_account(user_id) {
app.get("/account/delete", must_be_logged_in, function (req, res) {
if (!may_delete_account(req.user.user_id))
return res.status(401).send("You may not delete your account while you have unfinished games.")
- res.render("delete_account.pug")
+ res.render("account_delete.pug")
})
const SQL_SELECT_GAME_ROLE_FOR_DELETED_USER = SQL(`
@@ -733,7 +735,7 @@ app.post("/account/delete", must_be_logged_in, function (req, res) {
let user = SQL_SELECT_LOGIN.get(req.user.user_id)
let hash = hash_password(password, user.salt)
if (hash !== user.password)
- return res.render("delete_account.pug", { flash: "Wrong password!" })
+ return res.render("account_delete.pug", { flash: "Wrong password!" })
let list = SQL_SELECT_GAME_ROLE_FOR_DELETED_USER.all(req.user.user_id)
for (let item of list)
@@ -771,12 +773,12 @@ app.get("/account/mail/unsubscribe", must_be_logged_in, function (req, res) {
app.get("/account/webhook", must_be_logged_in, function (req, res) {
let webhook = SQL_SELECT_WEBHOOK.get(req.user.user_id)
- res.render("webhook.pug", { webhook: webhook })
+ res.render("account_webhook.pug", { webhook: webhook })
})
app.post("/account/webhook/delete", must_be_logged_in, function (req, res) {
SQL_DELETE_WEBHOOK.run(req.user.user_id)
- res.redirect("/webhook")
+ res.redirect("/account/webhook")
})
app.post("/account/webhook/update", must_be_logged_in, function (req, res) {
@@ -787,38 +789,38 @@ app.post("/account/webhook/update", must_be_logged_in, function (req, res) {
const webhook = SQL_SELECT_WEBHOOK_SEND.get(req.user.user_id)
if (webhook)
send_webhook(req.user.user_id, webhook, "Test message!", 0)
- res.setHeader("refresh", "3; url=/webhook")
+ res.setHeader("refresh", "3; url=/account/webhook")
res.send("Testing Webhook. Please wait...")
})
app.get("/account/change-name", must_be_logged_in, function (req, res) {
- res.render("change_name.pug")
+ res.render("account_change_name.pug")
})
app.post("/account/change-name", must_be_logged_in, function (req, res) {
let newname = clean_user_name(req.body.newname)
if (!is_valid_user_name(newname))
- return res.render("change_name.pug", { flash: "Invalid user name!" })
+ return res.render("account_change_name.pug", { flash: "Invalid user name!" })
if (SQL_EXISTS_USER_NAME.get(newname))
- return res.render("change_name.pug", { flash: "That name is already taken!" })
+ return res.render("account_change_name.pug", { flash: "That name is already taken!" })
if (!verify_password(req.user, req.body.password))
- return res.render("change_name.pug", { flash: "Wrong password!" })
+ return res.render("account_change_name.pug", { flash: "Wrong password!" })
SQL_UPDATE_USER_NAME.run(newname, req.user.user_id)
return res.redirect("/profile")
})
app.get("/account/change-mail", must_be_logged_in, function (req, res) {
- res.render("change_mail.pug")
+ res.render("account_change_mail.pug")
})
app.post("/account/change-mail", must_be_logged_in, function (req, res) {
let newmail = req.body.newmail
if (!is_valid_email(newmail) || is_forbidden_mail(newmail))
- return res.render("change_mail.pug", { flash: "Invalid mail address!" })
+ return res.render("account_change_mail.pug", { flash: "Invalid mail address!" })
if (SQL_EXISTS_USER_MAIL.get(newmail))
- return res.render("change_mail.pug", { flash: "That mail address is already taken!" })
+ return res.render("account_change_mail.pug", { flash: "That mail address is already taken!" })
if (!verify_password(req.user, req.body.password))
- return res.render("change_mail.pug", { flash: "Wrong password!" })
+ return res.render("account_change_mail.pug", { flash: "Wrong password!" })
SQL_UPDATE_USER_MAIL.run(newmail, req.user.user_id)
SQL_UPDATE_USER_VERIFIED.run(0, req.user.user_id)
SQL_UPDATE_USER_NOTIFY.run(0, req.user.user_id)
@@ -827,7 +829,7 @@ app.post("/account/change-mail", must_be_logged_in, function (req, res) {
app.get("/account/change-about", must_be_logged_in, function (req, res) {
let about = SQL_SELECT_USER_ABOUT.get(req.user.user_id)
- res.render("change_about.pug", { about })
+ res.render("account_change_about.pug", { about })
})
app.post("/account/change-about", must_be_logged_in, function (req, res) {
@@ -909,13 +911,13 @@ app.get("/contacts/search", must_be_logged_in, function (req, res) {
if (!q.includes("%"))
q = "%" + q + "%"
let results = SQL_SELECT_USER_BY_SEARCH.all(q)
- res.render("search_user.pug", {
+ res.render("contacts_search.pug", {
user: req.user,
search: req.query.q,
results
})
} else {
- res.render("search_user.pug", {
+ res.render("contacts_search.pug", {
user: req.user,
search: null,
results: null,
@@ -1823,7 +1825,7 @@ function get_title_page(req, res, title_id) {
let active_pools = TM_POOL_LIST_TITLE_ACTIVE.all(title_id)
let finished_pools = TM_POOL_LIST_TITLE_FINISHED.all(title_id)
- res.render("info.pug", {
+ res.render("title.pug", {
user: req.user,
title: title,
open_games,
@@ -1844,7 +1846,7 @@ app.get("/create/:title_id", function (req, res) {
let title = TITLE_TABLE[title_id]
if (!title)
return res.status(404).send("Invalid title.")
- res.render("create.pug", {
+ res.render("create_title.pug", {
user: req.user,
title: title,
limit: req.user ? check_create_game_limit(req.user) : null,
diff --git a/views/change_about.pug b/views/account_change_about.pug
index 7a0531e..7a0531e 100644
--- a/views/change_about.pug
+++ b/views/account_change_about.pug
diff --git a/views/change_mail.pug b/views/account_change_mail.pug
index 4d0605a..4d0605a 100644
--- a/views/change_mail.pug
+++ b/views/account_change_mail.pug
diff --git a/views/change_name.pug b/views/account_change_name.pug
index b1845ab..b1845ab 100644
--- a/views/change_name.pug
+++ b/views/account_change_name.pug
diff --git a/views/change_password.pug b/views/account_change_password.pug
index ca8e973..ca8e973 100644
--- a/views/change_password.pug
+++ b/views/account_change_password.pug
diff --git a/views/delete_account.pug b/views/account_delete.pug
index 54c3bc4..54c3bc4 100644
--- a/views/delete_account.pug
+++ b/views/account_delete.pug
diff --git a/views/forgot_password.pug b/views/account_forgot_password.pug
index 0913857..0913857 100644
--- a/views/forgot_password.pug
+++ b/views/account_forgot_password.pug
diff --git a/views/reset_password.pug b/views/account_reset_password.pug
index 8707ebc..8707ebc 100644
--- a/views/reset_password.pug
+++ b/views/account_reset_password.pug
diff --git a/views/webhook.pug b/views/account_webhook.pug
index b9817ef..b9817ef 100644
--- a/views/webhook.pug
+++ b/views/account_webhook.pug
diff --git a/views/search_user.pug b/views/contacts_search.pug
index 308cc41..308cc41 100644
--- a/views/search_user.pug
+++ b/views/contacts_search.pug
diff --git a/views/create-index.pug b/views/create_index.pug
index c508be7..c508be7 100644
--- a/views/create-index.pug
+++ b/views/create_index.pug
diff --git a/views/create.pug b/views/create_title.pug
index c4c5c2a..c4c5c2a 100644
--- a/views/create.pug
+++ b/views/create_title.pug
diff --git a/views/profile.pug b/views/profile.pug
index 2f9218d..0542a64 100644
--- a/views/profile.pug
+++ b/views/profile.pug
@@ -31,6 +31,8 @@ html
p <a href="/account/mail/subscribe">Enable mail notifications</a>
if mail.notify
p <a href="/account/mail/unsubscribe">Disable mail notifications</a>
+ else
+ p.error Mail notifications are disabled on this server.
if ENABLE_WEBHOOKS
if !webhook
@@ -43,6 +45,8 @@ html
dl
dt <a href="/account/webhook">Configure webhook</a>
dd= new URL(webhook.url).hostname
+ else
+ p.error Webhook notifications are disabled on this server.
h3 Account
diff --git a/views/stats_title.pug b/views/stats_title.pug
index 2107b93..aed6e63 100644
--- a/views/stats_title.pug
+++ b/views/stats_title.pug
@@ -19,7 +19,7 @@ html
tbody
each row in ratings
tr
- td <a class="black" href="user/#{row.name}">#{row.name}</a>
+ td <a class="black" href="/stats/user/#{row.name}">#{row.name}</a>
td.r= row.rating
td.r= row.count
td.r= row.last
diff --git a/views/info.pug b/views/title.pug
index 32837e9..32837e9 100644
--- a/views/info.pug
+++ b/views/title.pug