2019-02-27 20:39:31 +00:00
|
|
|
<?php
|
|
|
|
error_reporting(E_ALL ^ E_NOTICE);
|
|
|
|
|
|
|
|
include_once('../include/lucidAuth.functions.php');
|
2019-03-04 09:43:08 +00:00
|
|
|
|
2019-02-27 20:39:31 +00:00
|
|
|
if (!empty($_COOKIE['JWT'])) {
|
|
|
|
$validateTokenResult = validateToken($_COOKIE['JWT']);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($validateTokenResult['status'] === "Success") {
|
|
|
|
include_once('../include/lucidAuth.template.php');
|
|
|
|
|
2019-03-04 09:43:08 +00:00
|
|
|
try {
|
|
|
|
$allUsers = $pdoDB->query('
|
2019-03-06 13:21:47 +00:00
|
|
|
SELECT User.Id, User.Username, Role.Rolename
|
2019-03-04 09:43:08 +00:00
|
|
|
FROM User
|
2019-03-06 13:21:47 +00:00
|
|
|
LEFT JOIN Role
|
|
|
|
ON (Role.Id = User.RoleId)
|
2019-03-04 09:43:08 +00:00
|
|
|
')->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
} catch (Exception $e) {
|
|
|
|
// Should really do some actual errorhandling here
|
|
|
|
throw new Exception($e);
|
|
|
|
}
|
|
|
|
foreach($allUsers as $row) {
|
2019-03-06 13:21:47 +00:00
|
|
|
$tableRows[] = sprintf('<tr %1$s><td data-userid="%2$s">%3$s</td><td>%4$s</td><td class="immutable">%5$s</td></tr>',
|
|
|
|
$validateTokenResult['uid'] === $row['Id'] ? 'class="currentuser"': null,
|
2019-03-05 10:14:17 +00:00
|
|
|
$row['Id'],
|
2019-03-04 09:43:08 +00:00
|
|
|
explode('\\', $row['Username'])[1],
|
|
|
|
$row['Rolename'],
|
2019-03-06 13:21:47 +00:00
|
|
|
'<button class="bttn-simple bttn-xs bttn-primary" data-translation="button_sessions">Sessions</button>' . ($validateTokenResult['uid'] === $row['Id'] ? null : ' <button class="bttn-simple bttn-xs bttn-primary delete" data-translation="button_delete">Delete</button>')
|
2019-03-04 09:43:08 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2019-03-06 13:21:47 +00:00
|
|
|
echo sprintf($pageLayout['full_alt'],
|
2019-03-05 10:14:17 +00:00
|
|
|
sprintf($contentLayout['manage']['header'],
|
|
|
|
$validateTokenResult['name']
|
|
|
|
),
|
|
|
|
sprintf($contentLayout['manage']['section'],
|
2019-03-04 09:43:08 +00:00
|
|
|
implode($tableRows)
|
2019-03-05 10:14:17 +00:00
|
|
|
)
|
|
|
|
);
|
2019-02-27 20:39:31 +00:00
|
|
|
} else {
|
|
|
|
// No cookie containing valid authentication token found;
|
|
|
|
// explicitly deleting any remaining cookie, then redirecting to loginpage
|
|
|
|
setcookie('JWT', FALSE);
|
|
|
|
|
|
|
|
header("HTTP/1.1 401 Unauthorized");
|
|
|
|
header("Location: lucidAuth.login.php");
|
|
|
|
}
|
|
|
|
|
2019-02-25 14:00:32 +00:00
|
|
|
?>
|