First draft of session management for admins
This commit is contained in:
parent
160784c912
commit
6f53abf521
@ -8,6 +8,27 @@
|
||||
}
|
||||
|
||||
if ($validateTokenResult['status'] === "Success") {
|
||||
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
|
||||
}
|
||||
|
||||
// Return JSON object
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode([
|
||||
"Result" => "Success",
|
||||
"UserSessions" => json_encode( $moo )
|
||||
]);
|
||||
} else {
|
||||
// No action requested, default action
|
||||
include_once('../include/lucidAuth.template.php');
|
||||
|
||||
try {
|
||||
@ -27,7 +48,7 @@
|
||||
$row['Id'],
|
||||
explode('\\', $row['Username'])[1],
|
||||
$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>')
|
||||
);
|
||||
}
|
||||
|
||||
@ -39,6 +60,7 @@
|
||||
implode($tableRows)
|
||||
)
|
||||
);
|
||||
}
|
||||
} else {
|
||||
// No cookie containing valid authentication token found;
|
||||
// explicitly deleting any remaining cookie, then redirecting to loginpage
|
||||
|
@ -2,6 +2,18 @@ $(document).ready(function(){
|
||||
// Initialize the editable-table functionality
|
||||
$('#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() {
|
||||
$(this).closest('tr').addClass('removed');
|
||||
});
|
||||
@ -32,6 +44,9 @@ $(document).ready(function(){
|
||||
// To prevent recreating multiple new editors; reference the already existing `<input>`
|
||||
$('#usertable').editableTableWidget({editor: $('#editor')});
|
||||
// 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() {
|
||||
$(this).closest('tr').remove();
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user