[Web] Display app password name in last login (#4304)
parent
0e6672d9bf
commit
9946bb3427
|
@ -258,7 +258,7 @@ function last_login($action, $username, $sasl_limit_days = 7) {
|
||||||
switch ($action) {
|
switch ($action) {
|
||||||
case 'get':
|
case 'get':
|
||||||
if (filter_var($username, FILTER_VALIDATE_EMAIL) && hasMailboxObjectAccess($_SESSION['mailcow_cc_username'], $_SESSION['mailcow_cc_role'], $username)) {
|
if (filter_var($username, FILTER_VALIDATE_EMAIL) && hasMailboxObjectAccess($_SESSION['mailcow_cc_username'], $_SESSION['mailcow_cc_role'], $username)) {
|
||||||
$stmt = $pdo->prepare('SELECT `real_rip`, MAX(`datetime`) as `datetime`, `service`, `app_password` FROM `sasl_log`
|
$stmt = $pdo->prepare('SELECT `real_rip`, MAX(`datetime`) as `datetime`, `service`, `app_password`, MAX(`app_passwd`.`name`) as `app_password_name` FROM `sasl_log`
|
||||||
LEFT OUTER JOIN `app_passwd` on `sasl_log`.`app_password` = `app_passwd`.`id`
|
LEFT OUTER JOIN `app_passwd` on `sasl_log`.`app_password` = `app_passwd`.`id`
|
||||||
WHERE `username` = :username
|
WHERE `username` = :username
|
||||||
AND HOUR(TIMEDIFF(NOW(), `datetime`)) < :sasl_limit_days
|
AND HOUR(TIMEDIFF(NOW(), `datetime`)) < :sasl_limit_days
|
||||||
|
|
|
@ -101,10 +101,11 @@ jQuery(function($){
|
||||||
$.each(data.sasl, function (i, item) {
|
$.each(data.sasl, function (i, item) {
|
||||||
var datetime = new Date(item.datetime.replace(/-/g, "/"));
|
var datetime = new Date(item.datetime.replace(/-/g, "/"));
|
||||||
var local_datetime = datetime.toLocaleDateString(undefined, {year: "numeric", month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit", second: "2-digit"});
|
var local_datetime = datetime.toLocaleDateString(undefined, {year: "numeric", month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit", second: "2-digit"});
|
||||||
item.app_password ? app_password = ' <a href="/edit/app-passwd/' + item.app_password + '"><i class="bi bi-pen"></i> App</a>' : app_password = "", item.location ? ip_location = ' <span class="flag-icon flag-icon-' + item.location.toLowerCase() + '"></span>' : ip_location = "";
|
var service = '<div class="label label-default">' + item.service.toUpperCase() + '</div>';
|
||||||
service = '<div class="label label-default">' + item.service.toUpperCase() + '</div>';
|
var app_password = item.app_password ? ' <a href="/edit/app-passwd/' + item.app_password + '"><i class="bi bi-pen"></i> ' + escapeHtml(item.app_password_name || "App") + '</a>' : '';
|
||||||
item.real_rip.startsWith("Web") ? real_rip = item.real_rip : real_rip = '<a href="https://bgp.he.net/ip/' + item.real_rip + '" target="_blank">' + item.real_rip + "</a>";
|
var real_rip = item.real_rip.startsWith("Web") ? item.real_rip : '<a href="https://bgp.he.net/ip/' + item.real_rip + '" target="_blank">' + item.real_rip + "</a>";
|
||||||
ip_data = real_rip + ip_location + app_password;
|
var ip_location = item.location ? ' <span class="flag-icon flag-icon-' + item.location.toLowerCase() + '"></span>' : '';
|
||||||
|
var ip_data = real_rip + ip_location + app_password;
|
||||||
$(".last-login").append('<li class="list-group-item">' + local_datetime + " " + service + " " + lang.from + " " + ip_data + "</li>");
|
$(".last-login").append('<li class="list-group-item">' + local_datetime + " " + service + " " + lang.from + " " + ip_data + "</li>");
|
||||||
})
|
})
|
||||||
$('.last-login').append('</ul>');
|
$('.last-login').append('</ul>');
|
||||||
|
|
Loading…
Reference in New Issue