diff --git a/public/lucidAuth.manage.php b/public/lucidAuth.manage.php
index c6ea335..0096f3b 100644
--- a/public/lucidAuth.manage.php
+++ b/public/lucidAuth.manage.php
@@ -8,37 +8,59 @@
}
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 {
- $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) {
+ // 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 {
+ $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
- throw new Exception($e);
- }
- foreach($allUsers as $row) {
- $tableRows[] = sprintf('
%3$s | %4$s | %5$s |
',
- $validateTokenResult['uid'] === $row['Id'] ? ' class="currentuser"': null,
- $row['Id'],
- explode('\\', $row['Username'])[1],
- $row['Rolename'],
- '' . ($validateTokenResult['uid'] === $row['Id'] ? null : ' ')
- );
- }
+ throw new Exception($e);
+ }
+ foreach($allUsers as $row) {
+ $tableRows[] = sprintf('%3$s | %4$s | %5$s |
',
+ $validateTokenResult['uid'] === $row['Id'] ? ' class="currentuser"': null,
+ $row['Id'],
+ explode('\\', $row['Username'])[1],
+ $row['Rolename'],
+ '' . ($validateTokenResult['uid'] === $row['Id'] ? null : ' ')
+ );
+ }
- echo sprintf($pageLayout['full_alt'],
- sprintf($contentLayout['manage']['header'],
- $validateTokenResult['name']
- ),
- sprintf($contentLayout['manage']['section'],
- implode($tableRows)
- )
- );
+ echo sprintf($pageLayout['full_alt'],
+ sprintf($contentLayout['manage']['header'],
+ $validateTokenResult['name']
+ ),
+ sprintf($contentLayout['manage']['section'],
+ implode($tableRows)
+ )
+ );
+ }
} else {
// No cookie containing valid authentication token found;
// explicitly deleting any remaining cookie, then redirecting to loginpage
diff --git a/public/misc/script.manage.js b/public/misc/script.manage.js
index 2048dda..c4d3f15 100644
--- a/public/misc/script.manage.js
+++ b/public/misc/script.manage.js
@@ -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 ``
$('#usertable').editableTableWidget({editor: $('#editor')});
// Add eventhandlers to buttons of newly added ``
+ $('#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();
});