Periodic merge upstream #5
@ -8,37 +8,59 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($validateTokenResult['status'] === "Success") {
|
if ($validateTokenResult['status'] === "Success") {
|
||||||
include_once('../include/lucidAuth.template.php');
|
if ($_REQUEST['do'] === 'retrievesessions') {
|
||||||
|
$pdoQuery = $pdoDB->prepare('
|
||||||
|
SELECT SecureToken.Id, SecureToken.UserId, SecureToken.Value
|
||||||
|
FROM SecureToken
|
||||||
|
WHERE SecureToken.Id = :userid
|
||||||
|
');
|
||||||
|
$pdoQuery->execute([
|
||||||
|
':userid' => (int) $_REQUEST['userid']
|
||||||
|
]);
|
||||||
|
foreach($pdoQuery->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||||
|
//bla
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
// Return JSON object
|
||||||
$allUsers = $pdoDB->query('
|
header('Content-Type: application/json');
|
||||||
SELECT User.Id, User.Username, Role.Rolename
|
echo json_encode([
|
||||||
FROM User
|
"Result" => "Success",
|
||||||
LEFT JOIN Role
|
"UserSessions" => json_encode( $moo )
|
||||||
ON (Role.Id = User.RoleId)
|
]);
|
||||||
')->fetchAll(PDO::FETCH_ASSOC);
|
} else {
|
||||||
} catch (Exception $e) {
|
// No action requested, default action
|
||||||
|
include_once('../include/lucidAuth.template.php');
|
||||||
|
|
||||||
|
try {
|
||||||
|
$allUsers = $pdoDB->query('
|
||||||
|
SELECT User.Id, User.Username, Role.Rolename
|
||||||
|
FROM User
|
||||||
|
LEFT JOIN Role
|
||||||
|
ON (Role.Id = User.RoleId)
|
||||||
|
')->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
} catch (Exception $e) {
|
||||||
// Should really do some actual errorhandling here
|
// Should really do some actual errorhandling here
|
||||||
throw new Exception($e);
|
throw new Exception($e);
|
||||||
}
|
}
|
||||||
foreach($allUsers as $row) {
|
foreach($allUsers as $row) {
|
||||||
$tableRows[] = sprintf('<tr%1$s><td data-userid="%2$s">%3$s</td><td>%4$s</td><td class="immutable">%5$s</td></tr>',
|
$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,
|
$validateTokenResult['uid'] === $row['Id'] ? ' class="currentuser"': null,
|
||||||
$row['Id'],
|
$row['Id'],
|
||||||
explode('\\', $row['Username'])[1],
|
explode('\\', $row['Username'])[1],
|
||||||
$row['Rolename'],
|
$row['Rolename'],
|
||||||
'<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>')
|
'<button class="bttn-simple bttn-xs bttn-primary session" 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>')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
echo sprintf($pageLayout['full_alt'],
|
echo sprintf($pageLayout['full_alt'],
|
||||||
sprintf($contentLayout['manage']['header'],
|
sprintf($contentLayout['manage']['header'],
|
||||||
$validateTokenResult['name']
|
$validateTokenResult['name']
|
||||||
),
|
),
|
||||||
sprintf($contentLayout['manage']['section'],
|
sprintf($contentLayout['manage']['section'],
|
||||||
implode($tableRows)
|
implode($tableRows)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// No cookie containing valid authentication token found;
|
// No cookie containing valid authentication token found;
|
||||||
// explicitly deleting any remaining cookie, then redirecting to loginpage
|
// explicitly deleting any remaining cookie, then redirecting to loginpage
|
||||||
|
@ -2,6 +2,18 @@ $(document).ready(function(){
|
|||||||
// Initialize the editable-table functionality
|
// Initialize the editable-table functionality
|
||||||
$('#usertable').editableTableWidget();
|
$('#usertable').editableTableWidget();
|
||||||
|
|
||||||
|
// Add eventhandlers to buttons
|
||||||
|
$('#usertable button.session').click(function() {
|
||||||
|
$.post("lucidAuth.manage.php", {
|
||||||
|
do: "retrievesessions",
|
||||||
|
userid: $(this).closest('tr').find('td:nth-child(1)').data('userid')
|
||||||
|
})
|
||||||
|
.done(function(data,_status) {
|
||||||
|
if (data.Result === 'Success') {
|
||||||
|
} else {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
$('#usertable button.delete').click(function() {
|
$('#usertable button.delete').click(function() {
|
||||||
$(this).closest('tr').addClass('removed');
|
$(this).closest('tr').addClass('removed');
|
||||||
});
|
});
|
||||||
@ -32,6 +44,9 @@ $(document).ready(function(){
|
|||||||
// To prevent recreating multiple new editors; reference the already existing `<input>`
|
// To prevent recreating multiple new editors; reference the already existing `<input>`
|
||||||
$('#usertable').editableTableWidget({editor: $('#editor')});
|
$('#usertable').editableTableWidget({editor: $('#editor')});
|
||||||
// Add eventhandlers to buttons of newly added `<tr>`
|
// Add eventhandlers to buttons of newly added `<tr>`
|
||||||
|
$('#usertable .new button.session').unbind().click(function() {
|
||||||
|
console.log('New user, unlikely to have sessions already, lets do nothing for now');
|
||||||
|
});
|
||||||
$('#usertable .new button.delete').unbind().click(function() {
|
$('#usertable .new button.delete').unbind().click(function() {
|
||||||
$(this).closest('tr').remove();
|
$(this).closest('tr').remove();
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user