mirror of
https://github.com/Akif9748/akf-forum.git
synced 2024-11-26 21:30:42 +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 |
|
| Admin | 🟢 | HIGH |
|
||||||
| Message count | 🟢 | MEDIUM |
|
| Message count | 🟢 | MEDIUM |
|
||||||
| Delete user | 🟢 | HIGH |
|
| Delete user | 🟢 | HIGH |
|
||||||
| Undelete | 🔴 | MEDIUM |
|
| Undelete | 🟢 | MEDIUM |
|
||||||
| About me | 🔴 | LOW |
|
| About me | 🔴 | LOW |
|
||||||
| Edit user | 🔴 | HIGH |
|
| Edit user | 🔴 | HIGH |
|
||||||
| IP ban | 🔴 | MEDIUM |
|
| IP ban | 🔴 | MEDIUM |
|
||||||
|
|
|
@ -32,7 +32,7 @@ app.post("/:id/delete/", async (req, res) => {
|
||||||
app.post("/:id/undelete/", 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.");
|
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 ) return res.error(404, `We don't have any user with id ${req.params.id}.`);
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
||||||
<%- include("extra/meta", {title: "User list!" }) %>
|
<%- include("extra/meta", {title: member.name }) %>
|
||||||
|
|
||||||
|
|
||||||
<body style="text-align: center;">
|
<body style="text-align: center;">
|
||||||
|
@ -66,8 +66,9 @@
|
||||||
|
|
||||||
const response = await request("/api/users/<%= member.id %>/delete");
|
const response = await request("/api/users/<%= member.id %>/delete");
|
||||||
|
|
||||||
if (response.deleted)
|
if (!response.deleted) return
|
||||||
alert("User Deleted");
|
alert("User is deleted!");
|
||||||
|
location.reload()
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -76,6 +77,26 @@
|
||||||
<% }; %>
|
<% }; %>
|
||||||
<% if (member.deleted) {%>
|
<% if (member.deleted) {%>
|
||||||
<h1>This user has been deleted!</h1>
|
<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>
|
</body>
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
<div class="user-box">
|
<div class="user-box">
|
||||||
<img src="<%=user.avatar %>" class="user-box-img">
|
<img src="<%=user.avatar %>" class="user-box-img">
|
||||||
<div class="user-box-title"> <a href="<%= user.getLink() %>">
|
<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>
|
<%= user.name %></a></div>
|
||||||
</div>
|
</div>
|
||||||
<% }); %>
|
<% }); %>
|
||||||
|
|
Loading…
Reference in a new issue