Anwärter löschen
This commit is contained in:
parent
3275c31192
commit
97a119efe0
2
app.js
2
app.js
|
@ -284,6 +284,8 @@ app.post('/userrights', requireAuth, requireAdmin, async (req, res) => {
|
||||||
}
|
}
|
||||||
else if (type === 'admint') {
|
else if (type === 'admint') {
|
||||||
await pool.query('UPDATE users SET role = $1, admin_temp = $2 WHERE id = $3', ['admin', moment().toDate() , userId]);
|
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');
|
res.redirect('/admin');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
|
@ -35,12 +35,17 @@
|
||||||
<% users.forEach(user => { %>
|
<% users.forEach(user => { %>
|
||||||
<li>
|
<li>
|
||||||
<%= user.username %> - <%= user.email %>
|
<%= user.username %> - <%= user.email %>
|
||||||
<% if (user.role === '0') { %>
|
<% if (!user.is_active) { %>
|
||||||
<form action="/userrights" method="post" style="display: inline;">
|
<form action="/userrights" method="post" style="display: inline;">
|
||||||
<input type="hidden" name="type" value="activate">
|
<input type="hidden" name="type" value="activate">
|
||||||
<input type="hidden" name="userId" value="<%= user.id %>">
|
<input type="hidden" name="userId" value="<%= user.id %>">
|
||||||
<button type="submit" class="btn btn-success">Activate</button>
|
<button type="submit" class="btn btn-success">Activate</button>
|
||||||
</form>
|
</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') { %>
|
<% } else if (user.role === 'user') { %>
|
||||||
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#adminModal">
|
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#adminModal">
|
||||||
Admin
|
Admin
|
||||||
|
|
Loading…
Reference in New Issue