Fix last logins on dashboard to show usernames, and for admin display all users from the past 3 days

This commit is contained in:
Ilia Ross
2025-08-27 16:54:44 +03:00
parent 8f508724e4
commit 16110e3e3e

View File

@@ -20,7 +20,12 @@ foreach my $k (keys %sessiondb) {
next if ($k =~ /^1111111/);
next if (!$sessiondb{$k});
my ($user, $ltime, $lip) = split(/\s+/, $sessiondb{$k});
next if ($user ne $remote_user && $user ne "!".$remote_user);
next if (&webmin_user_is_admin()
? ($user eq "!" ||
($user ne $remote_user &&
# Show all logins for past 3 days for admin
$ltime && $ltime < time() - 3*24*60*60))
: ($user ne $remote_user && $user ne "!".$remote_user));
push(@logins, [ $user, $ltime, $lip, $k ]);
}
if (@logins) {
@@ -29,6 +34,7 @@ if (@logins) {
@logins = @logins[0..4];
}
my $html = &ui_columns_start([ $text{'sessions_host'},
$text{'sessions_user'},
$text{'sessions_login'},
$text{'sessions_state'},
$text{'sessions_action'} ]);
@@ -62,8 +68,11 @@ if (@logins) {
&ui_link("@{[&get_webprefix()]}/acl/delete_session.cgi?id=$l->[3]&redirect_ref=1",
$text{'sessions_kill'}))
}
my $user = $l->[0];
$user =~ s/^\!//;
$html .= &ui_columns_row([
$l->[2],
$user,
&make_date($l->[1]),
$state,
&ui_links_row(\@links) ]);