Anwärter löschen

This commit is contained in:
Klaas 2024-05-29 21:06:42 +02:00
parent 3275c31192
commit 97a119efe0
2 changed files with 8 additions and 1 deletions

2
app.js
View File

@ -284,6 +284,8 @@ app.post('/userrights', requireAuth, requireAdmin, async (req, res) => {
}
else if (type === 'admint') {
await pool.query('UPDATE users SET role = $1, admin_temp = $2 WHERE id = $3', ['admin', moment().toDate() , userId]);
} else if (type === 'delete') {
await pool.query('DELETE FROM users WHERE id = $1', [userId]);
}
res.redirect('/admin');
} catch (error) {

View File

@ -35,12 +35,17 @@
<% users.forEach(user => { %>
<li>
<%= user.username %> - <%= user.email %>
<% if (user.role === '0') { %>
<% if (!user.is_active) { %>
<form action="/userrights" method="post" style="display: inline;">
<input type="hidden" name="type" value="activate">
<input type="hidden" name="userId" value="<%= user.id %>">
<button type="submit" class="btn btn-success">Activate</button>
</form>
<form action="/userrights" method="post" style="display: inline;">
<input type="hidden" name="type" value="delete">
<input type="hidden" name="userId" value="<%= user.id %>">
<button type="submit" class="btn btn-danger">Delete</button>
</form>
<% } else if (user.role === 'user') { %>
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#adminModal">
Admin