Skip to content

Commit

Permalink
adapt /userLastLogins (GLPI UP1#153277)
Browse files Browse the repository at this point in the history
  • Loading branch information
prigaux committed Sep 26, 2023
1 parent 84bedcc commit ef8f1c8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
14 changes: 2 additions & 12 deletions userLastLogins.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
if (preg_match('/^#/', $line)) break;
$e = json_decode($line, true);
$action = getAndUnset($e, 'action');
if ($action !== 'TICKET_GRANTING_TICKET_CREATED') {
if ($action === 'AUTHENTICATION_FAILED') {
$e['error'] = $action;
}
$list[] = $e;
Expand All @@ -30,7 +30,7 @@
# all remaining $lines are "similar login failures"
$fuzzy_failed = array_map(json_decode, $lines);

$since = compute_since_from_audit_boundary_dates($audit_boundary_dates);
$since = [ $audit_boundary_dates[0] ];


# sort by date (needed since it is an aggregation of login logs + mail logs)
Expand All @@ -40,14 +40,4 @@
echoJson(array("since" => $since, "list" => $list, "fuzzy_failed" => $fuzzy_failed));


function compute_since_from_audit_boundary_dates($l) {
$start1 = $l[0][0]; $end1 = $l[0][1];
$start2 = $l[1][0]; $end2 = $l[1][1];
if (strcmp($end1, $start2) <= 0 || strcmp($end2, $start1) <= 0) {
return [$start1, $start2];
} else {
return [min($start1, $start2)];
}
}

?>
4 changes: 2 additions & 2 deletions web-widget/userinfo/userinfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -684,14 +684,14 @@ function formatLastLogins(info, data, div) {
if (data.list.length) {
var details = $("<div class='vertical-scroll hidden'>");
$.each(data.list, function (v, e) {
var t = formatDateTime(e.when) + " : " + (e.error || "SUCCESS") + " <small>(login = " + e.who + ", ip = " + e.ip + " )</small>";
var t = formatDateTime(e.when) + " : " + (e.error || "SUCCESS") + " <small>(login = " + e.login + ", ip = " + e.ip + " )</small>";
details.append(t + '<br>');
})
if (data.fuzzy_failed.length) {
details.append("<br>Logins en échec avec login légèrement différent :<br>");
}
$.each(data.fuzzy_failed, function (v, e) {
var t = formatDateTime(e.when) + " : " + e.who + " FAILED <small>(ip = " + e.ip + " )</small>";
var t = formatDateTime(e.when) + " : " + e.login + " FAILED <small>(ip = " + e.ip + " )</small>";
details.append(t + '<br>');
})
div.append($("<span class='clickable'>").append(" <small>details</small>").click(function () { details.toggleClass("hidden") }));
Expand Down

0 comments on commit ef8f1c8

Please sign in to comment.