mirror of
https://github.com/Akif9748/akf-forum.git
synced 2024-11-22 20:10:40 +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,7 +32,7 @@ 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}.`);
|
||||
|
||||
|
|
|
@ -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,8 +66,9 @@
|
|||
|
||||
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()
|
||||
|
||||
});
|
||||
|
||||
|
@ -76,6 +77,26 @@
|
|||
<% }; %>
|
||||
<% 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>
|
||||
|
||||
|
|
|
@ -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