fix: back to password in session, add list users in admin panel, modify, delete, logout
This commit is contained in:
46
views/list_users.php
Normal file
46
views/list_users.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
// Check if user is logged in and is admin
|
||||
if (!isset($_SESSION["login"]) || !$_SESSION["is_admin"]) {
|
||||
header("Location: ../index.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once __DIR__ . '/../controllers/controllerAdmin.php';
|
||||
|
||||
echo "<h2>Gestion des utilisateurs</h2>";
|
||||
|
||||
// Display users table
|
||||
echo "<table border='1'>
|
||||
<tr>
|
||||
<th>Nom</th>
|
||||
<th>Email</th>
|
||||
<th>OU</th>
|
||||
<th>Actions</th>
|
||||
</tr>";
|
||||
|
||||
$users = listAllUsers();
|
||||
foreach ($users as $user) {
|
||||
$name = htmlspecialchars($user['cn'][0]);
|
||||
$email = htmlspecialchars($user['mail'][0] ?? 'N/A');
|
||||
$ou = htmlspecialchars($user['ou']);
|
||||
$dn = htmlspecialchars($user['distinguishedname'][0]);
|
||||
|
||||
echo "<tr>
|
||||
<td>$name</td>
|
||||
<td>$email</td>
|
||||
<td>$ou</td>
|
||||
<td>
|
||||
<form method='post' action='edit_user.php' style='display:inline;'>
|
||||
<input type='hidden' name='user_dn' value='$dn'>
|
||||
<input type='submit' value='Modifier'>
|
||||
</form>
|
||||
<form method='post' action='delete_user.php' style='display:inline;' onsubmit='return confirm(\"Confirmer la suppression ?\");'>
|
||||
<input type='hidden' name='user_dn' value='$dn'>
|
||||
<input type='submit' value='Supprimer'>
|
||||
</form>
|
||||
</td>
|
||||
</tr>";
|
||||
}
|
||||
echo "</table>";
|
||||
Reference in New Issue
Block a user