Tag creation for approved users

This commit is contained in:
mid
2024-07-18 22:53:44 +03:00
parent bccc0ef742
commit 61fd417013
8 changed files with 213 additions and 34 deletions

View File

@@ -65,6 +65,31 @@ local handler = function(req, res)
res:statusCode(403)
end
res:write""
elseif req:path():match"^/addtags/?$" then
if verified and verified.privs >= DB.USER_PRIVS_APPROVED then
local pohst = req:post()
local returndata = {}
if pohst.csrf and DB.csrfverify(verified.id, Escapes.urlunescape(pohst.csrf)) then
local names = pohst["name[]"]
local tcs = pohst["tc[]"]
local adults = pohst["adult[]"]
if #names == #tcs and #names == #adults then
for tag = 1, #names do
local tagid = DB.tagadd(tostring(names[tag]), (tonumber(tcs[tag]) or 0) + 1, tostring(adults[tag]) == "1")
table.insert(returndata, tagid)
end
end
end
res:statusCode(200)
res:write(table.concat(returndata, ","))
else
res:statusCode(403)
res:write""
end
elseif req:path():match"^/verif/?$" then
res:addHeader("Set-Cookie", "sesh=" .. (req.querystring.q or "") .. "; SameSite=Lax; Secure; HttpOnly")
res:addHeader("Location", "/")
@@ -183,4 +208,4 @@ local handler = function(req, res)
end
end
return handler
return handler