Added usermenu & hide last seen

This commit is contained in:
Akif9748 2022-10-09 22:25:03 +03:00
parent 02364c91ed
commit 47cda470e2
3 changed files with 111 additions and 92 deletions

View file

@ -52,16 +52,15 @@ Akf-forum has got an API for AJAX (fetch), other clients etc. And, you can learn
- categories page is need a update, thread count in category
- Disable last seen button for web.
- old contents / titles add to forum interface
- add ban button to user profile.
- add ban button to user profile.?
- change password.
- add approval threads page.
- who liked a message for web.
- edit config from web admin panel.
- user.state for ban, delete, etc.
- Add a feature list to README.md
- delete admin???
- change category name
- theme support++, directly edit html!
## Major Version History
- V4: Caching
- V3: New Theme

View file

@ -38,7 +38,7 @@ app.patch("/:id", async (req, res) => {
if (req.user.id !== member.id && !user.admin) return res.error(403, "You have not got permission for this.");
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;
const { name, about, theme, admin, deleted, hideLastSeen } = req.body;
if ((admin?.length || "deleted" in req.body) && !req.user.admin) return res.error(403, "You have not got permission for edit 'admin' and 'deleted' information, or bad request.");
const { names, desp } = req.app.get("limits");
@ -56,6 +56,9 @@ app.patch("/:id", async (req, res) => {
if (typeof admin === "boolean" || ["false", "true"].includes(admin)) member.admin = admin;
if (deleted === false) member.deleted = false;
if (typeof hideLastSeen === "boolean") member.hideLastSeen = hideLastSeen;
member.edited = true;
res.complate(await member.save());

View file

@ -13,12 +13,18 @@
<div class="content">
<% if(user?.admin || user?.id === member.id){ %>
<details>
<summary class="btn-outline-primary">User Menu:</summary>
<% if (!member.discordID && discord && user?.id === member.id) { %>
<a href="<%=discord%>" class="btn-outline-primary">Auth with discord</a>
<a href="<%=discord%>" class="btn-outline-primary">DC auth</a>
<% } else if(member.discordID && user?.id === member.id) { %>
<a class="btn-outline-primary" id="un_discord">Unauth with discord!</a>
<a class="btn-outline-primary" id="un_discord">Unauth DC!</a>
<% } %>
<% if (user?.admin || user?.id === member.id) { %>
<a href="/users/<%=member.id%>/avatar" class="btn-outline-primary">Upload avatar</a>
<link rel="stylesheet" href="/css/modal.css" />
@ -42,9 +48,7 @@
<button class="btn-primary" style="width:100%;">Update User!</button>
</form>
</div>
</div>
</div>
@ -72,6 +76,14 @@
});
alert(await response.text());
location.reload()
} else if (e.target.id.startsWith("last_")) {
let hideLastSeen = e.target.id.replace("last_", "") == "hide" ? true : false;
const response = await request("/api/users/<%= member.id %>/", "PATCH", {
hideLastSeen
});
alert(`Last seen is ${!hideLastSeen?"un":""}hided!`);
location.reload()
} else if (e.target.id == "toogle")
document.getElementById('user-edit').classList.toggle('no-active')
@ -88,6 +100,11 @@
location.reload();
});
</script>
<% if (member.hideLastSeen) {%>
<a id="last_unhide" class="btn-primary">Unhide last seen! </a>
<% } else { %>
<a id="last_hide" class="btn-outline-primary">Hide last seen! </a>
<% } %>
<% if (member.deleted) {%>
@ -97,16 +114,16 @@
<a id="delete" class="btn-outline-primary">Delete user! </a>
<% } %>
<% if (user?.admin) {%>
<details>
<summary class="btn-outline-primary">IP adresses of user:</summary>
<h2>IP adresses of the user:</h2>
<select>
<% for(const ip of member.ips) { %>
<option><%= ip %></option>
<% } %>
</select>
</details>
<% } %>
</details>
<% } %>
<div class="box" style="justify-content:center;">
<img style="width:150px;height:150px;border-radius:50%;" src="<%=member.avatar %>">