diff --git a/README.md b/README.md index 72ffbca..1232251 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,8 @@ Akf-forum has got an API for AJAX (fetch), other clients etc. And, you can learn - edit config from web admin panel. - user.state for ban, delete, etc. - Add a feature list to README.md +- delete admin??? +- MODALS'S CSS & JS ## Major Version History - V4: Caching - V3: New Theme diff --git a/index.js b/index.js index 86494bb..fcd42be 100644 --- a/index.js +++ b/index.js @@ -35,7 +35,7 @@ app.use(express.static("public"), express.json(), express.urlencoded({ extended: res.error = (type, error) => res.reply("error", { type, error }, type); - if (req.user && !req.user.approved && !req.url.startsWith("/auth/email")) return res.error(403, "Your account is not approved yet."); + if (req.user && !req.user.approved&& !req.user.admin && !req.url.startsWith("/auth/email")) return res.error(403, "Your account is not approved yet."); if (req.user?.deleted) { req.session.destroy(); diff --git a/public/css/thread.css b/public/css/thread.css index c27a5d4..753a4f7 100644 --- a/public/css/thread.css +++ b/public/css/thread.css @@ -86,10 +86,14 @@ display: none; } -.dots-menu.active { +.active { display: block; } +.no-display { + display: none; +} + .dots-menu a { display: block; margin: 8px; @@ -105,12 +109,6 @@ } -.send>textarea{ - font-family:inherit; - width: 100%; - margin: 10px; - border: 2px solid #e3e3e3; -} /* Media Query */ @media(max-width:980px) { @@ -170,7 +168,7 @@ width: 120px; } - .dots-menu.active { + .active { display: flex; } diff --git a/public/js/modal.js b/public/js/modal.js new file mode 100644 index 0000000..4ace875 --- /dev/null +++ b/public/js/modal.js @@ -0,0 +1,3 @@ +for (const modal of document.querySelectorAll("[modal]")) + modal.onclick = () => { + document.querySelector(modal.getAttribute("modal")).classList.toggle('active')}; \ No newline at end of file diff --git a/routes/api/routes/messages.js b/routes/api/routes/messages.js index 8c90043..192bb1f 100644 --- a/routes/api/routes/messages.js +++ b/routes/api/routes/messages.js @@ -39,7 +39,7 @@ app.patch("/:id/", async (req, res) => { const { message, user } = req; if (user.id !== message.authorID && !user.admin) return res.error(403, "You have not got permission for this."); - if (!Object.values(req.body).some(Boolean)) return res.error(400, "Missing message informations for update in request body."); + if (!Object.keys(req.body).some(Boolean)) return res.error(400, "Missing message informations for update in request body."); const { content, deleted } = req.body; const limits = req.app.get("limits"); diff --git a/routes/api/routes/users.js b/routes/api/routes/users.js index 8f686ed..0fcd2bf 100644 --- a/routes/api/routes/users.js +++ b/routes/api/routes/users.js @@ -36,7 +36,7 @@ app.patch("/:id", async (req, res) => { const { user, member } = req; if (req.user.id !== member.id && !user.admin) return res.error(403, "You have not got permission for this."); - if (!Object.values(req.body).some(Boolean)) return res.error(400, "Missing member informations in request body."); + if (!Object.keys(req.body).some(Boolean)) return res.error(400, "Missing member informations in request body."); const { name, about, theme, admin, deleted } = req.body; diff --git a/views/thread.ejs b/views/thread.ejs index 1bb41b8..7f40045 100644 --- a/views/thread.ejs +++ b/views/thread.ejs @@ -24,16 +24,16 @@
<%= thread.author.name %> <%= "• "+(thread.edited ? "Edited" : "Not edited")%>
+ +
<% if ((user.id === thread.authorID || user.admin ) && thread.state !== "DELETED"){ %> - DELETE EDIT <% } else if (thread.state == "DELETED") { %> -

This thread has been deleted

+

This thread has been deleted

UNDELETE - <% }; %>
@@ -44,7 +44,7 @@
- +
<%= new Date(message.time).toLocaleDateString() %>
@@ -57,7 +57,7 @@ <% if(user){ %> <% if(user.id === message.authorID || user.admin){ %> -
+
<% if (message.deleted){ %> <% } %> @@ -67,7 +67,7 @@
-
+