add deleting, promoting/demoting, guesting (soft banning) users

This commit is contained in:
2025-05-19 18:34:21 +03:00
parent 349f4d38ef
commit a5a7175365
14 changed files with 234 additions and 37 deletions

View File

@ -27,7 +27,7 @@ end)
app:get("topic_create", "/create", function(self)
local user = util.get_logged_in_user(self) or util.TransientUser
if not user:is_admin() then
if not user:is_mod() then
return {status = 403}
end
@ -36,7 +36,7 @@ end)
app:post("topic_create", "/create", function(self)
local user = util.get_logged_in_user(self) or util.TransientUser
if not user:is_admin() then
if not user:is_mod() then
return {redirect_to = "all_topics"}
end
@ -72,7 +72,7 @@ app:get("topic", "/:slug", function(self)
self.thread_create_error = ThreadCreateError.GUEST
elseif user:is_guest() then
self.thread_create_error = ThreadCreateError.LOGGED_OUT
elseif util.ntob(topic.is_locked) and not user:is_admin() then
elseif util.ntob(topic.is_locked) and not user:is_mod() then
self.thread_create_error = ThreadCreateError.TOPIC_LOCKED
end
@ -81,7 +81,7 @@ end)
app:get("topic_edit", "/:slug/edit", function(self)
local user = util.get_logged_in_user_or_transient(self)
if not user:is_admin() then
if not user:is_mod() then
return {redirect_to = self:url_for("topic", {slug = self.params.slug})}
end
local topic = Topics:find({
@ -96,7 +96,7 @@ end)
app:post("topic_edit", "/:slug/edit", function(self)
local user = util.get_logged_in_user_or_transient(self)
if not user:is_admin() then
if not user:is_mod() then
return {redirect_to = self:url_for("topic", {slug = self.params.slug})}
end
local topic = Topics:find({