2022-09-13 13:14:49 +00:00
|
|
|
<?php
|
|
|
|
namespace Misuzu;
|
|
|
|
|
|
|
|
use Misuzu\Pagination;
|
|
|
|
|
2024-12-02 02:28:08 +00:00
|
|
|
if(!isset($msz) || !($msz instanceof \Misuzu\MisuzuContext))
|
|
|
|
die('Script must be called through the Misuzu route dispatcher.');
|
|
|
|
|
2024-11-30 04:09:29 +00:00
|
|
|
$currentUser = $msz->authInfo->userInfo;
|
2023-08-31 15:59:53 +00:00
|
|
|
if($currentUser === null)
|
|
|
|
Template::throwError(401);
|
2022-09-13 13:14:49 +00:00
|
|
|
|
2024-12-19 01:22:26 +00:00
|
|
|
$loginHistoryPagination = Pagination::fromInput($msz->authCtx->loginAttempts->countAttempts(userInfo: $currentUser), 5, 'hp');
|
|
|
|
$accountLogPagination = Pagination::fromInput($msz->auditLog->countLogs(userInfo: $currentUser), 10, 'ap');
|
2023-07-17 17:43:17 +00:00
|
|
|
|
2024-11-30 04:09:29 +00:00
|
|
|
$loginHistory = iterator_to_array($msz->authCtx->loginAttempts->getAttempts(userInfo: $currentUser, pagination: $loginHistoryPagination));
|
|
|
|
$auditLogs = iterator_to_array($msz->auditLog->getLogs(userInfo: $currentUser, pagination: $accountLogPagination));
|
2022-09-13 13:14:49 +00:00
|
|
|
|
|
|
|
Template::render('settings.logs', [
|
2023-07-22 16:37:57 +00:00
|
|
|
'login_history_list' => $loginHistory,
|
2022-09-13 13:14:49 +00:00
|
|
|
'login_history_pagination' => $loginHistoryPagination,
|
2023-07-17 17:43:17 +00:00
|
|
|
'account_log_list' => $auditLogs,
|
2022-09-13 13:14:49 +00:00
|
|
|
'account_log_pagination' => $accountLogPagination,
|
|
|
|
]);
|