mirror of
https://github.com/Akif9748/akf-forum.git
synced 2024-12-22 23:59:08 +03:00
Undelete user
Co-authored-by: Zeynep <zeynepkotan50@gmail.com>
This commit is contained in:
parent
1624430551
commit
258578e790
4 changed files with 31 additions and 10 deletions
|
@ -44,7 +44,7 @@ And, you can learn about API in `util/APIDOCS.md`.
|
|||
| Admin | 🟢 | HIGH |
|
||||
| Message count | 🟢 | MEDIUM |
|
||||
| Delete user | 🟢 | HIGH |
|
||||
| Undelete | 🔴 | MEDIUM |
|
||||
| Undelete | 🟢 | MEDIUM |
|
||||
| About me | 🔴 | LOW |
|
||||
| Edit user | 🔴 | HIGH |
|
||||
| IP ban | 🔴 | MEDIUM |
|
||||
|
|
|
@ -32,10 +32,10 @@ app.post("/:id/delete/", async (req, res) => {
|
|||
app.post("/:id/undelete/", async (req, res) => {
|
||||
if (!req.user.admin) return res.error(403, "You have not got permission for this.");
|
||||
|
||||
const member = await UserModel.get(id);
|
||||
const member = await UserModel.get(req.params.id);
|
||||
|
||||
if (!member ) return res.error(404, `We don't have any user with id ${req.params.id}.`);
|
||||
|
||||
|
||||
if (!member.deleted) return res.error(404, "This user is not deleted, first, delete it.");
|
||||
|
||||
member.deleted = false;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<%- include("extra/meta", {title: "User list!" }) %>
|
||||
<%- include("extra/meta", {title: member.name }) %>
|
||||
|
||||
|
||||
<body style="text-align: center;">
|
||||
|
@ -66,17 +66,38 @@
|
|||
|
||||
const response = await request("/api/users/<%= member.id %>/delete");
|
||||
|
||||
if (response.deleted)
|
||||
alert("User Deleted");
|
||||
if (!response.deleted) return
|
||||
alert("User is deleted!");
|
||||
location.reload()
|
||||
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
<% }; %>
|
||||
<% if (member.deleted) {%>
|
||||
<% }; %>
|
||||
<% if (member.deleted) {%>
|
||||
<h1>This user has been deleted!</h1>
|
||||
<% }; %>
|
||||
|
||||
<form id="undelete">
|
||||
<button class="big" type="submit">Undelete user!</button>
|
||||
</form>
|
||||
|
||||
<script type="module">
|
||||
|
||||
import request from "../../js/request.js";
|
||||
|
||||
document.addEventListener("submit", async e => {
|
||||
|
||||
const response = await request("/api/users/<%= member.id %>/undelete");
|
||||
|
||||
if (response.deleted) return;
|
||||
alert("User is undeleted successfully!");
|
||||
location.reload()
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
<% }; %>
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -14,7 +14,7 @@
|
|||
<div class="user-box">
|
||||
<img src="<%=user.avatar %>" class="user-box-img">
|
||||
<div class="user-box-title"> <a href="<%= user.getLink() %>">
|
||||
<% if (user.deleted) { %> <span>[DELETED]</span><% } %>
|
||||
<% if (user.deleted) { %> <span style="color: RED;">[DELETED]</span><% } %>
|
||||
<%= user.name %></a></div>
|
||||
</div>
|
||||
<% }); %>
|
||||
|
|
Loading…
Reference in a new issue