Make request and access log work
This commit is contained in:
parent
eb7bdb3fbc
commit
fb788c9c0a
|
|
@ -7,6 +7,7 @@ use Redirect;
|
|||
use Validator;
|
||||
use BackendAuth;
|
||||
use Backend\Models\User;
|
||||
use Backend\Models\AccessLog;
|
||||
use Backend\Classes\Controller;
|
||||
use System\Classes\VersionManager;
|
||||
use System\Classes\ApplicationException;
|
||||
|
|
@ -73,6 +74,9 @@ class Auth extends Controller
|
|||
'password' => post('password')
|
||||
], true);
|
||||
|
||||
// Log the sign in event
|
||||
AccessLog::add($user);
|
||||
|
||||
// Load version updates
|
||||
VersionManager::instance()->updateAll();
|
||||
|
||||
|
|
|
|||
|
|
@ -16,9 +16,10 @@ use Twig_Environment;
|
|||
use Controller as BaseController;
|
||||
use Cms\Twig\Loader as TwigLoader;
|
||||
use Cms\Twig\Extension as CmsTwigExtension;
|
||||
use System\Twig\Extension as SystemTwigExtension;
|
||||
use Cms\Classes\FileHelper as CmsFileHelper;
|
||||
use System\Models\RequestLog;
|
||||
use System\Classes\ErrorHandler;
|
||||
use System\Twig\Extension as SystemTwigExtension;
|
||||
use October\Rain\Support\Markdown;
|
||||
use October\Rain\Support\ValidationException;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
|
|
@ -141,6 +142,9 @@ class Controller extends BaseController
|
|||
if (!$page) {
|
||||
$this->setStatusCode(404);
|
||||
|
||||
// Log the 404 request
|
||||
RequestLog::add();
|
||||
|
||||
if (!$page = $this->router->findByUrl('/404'))
|
||||
return Response::make(View::make('cms::404'), $this->statusCode);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,11 +23,12 @@ class RequestLog extends Model
|
|||
* Creates a log record
|
||||
* @return self
|
||||
*/
|
||||
public static function add()
|
||||
public static function add($statusCode = 404)
|
||||
{
|
||||
$record = static::firstOrNew([
|
||||
'url' => Request::fullUrl(),
|
||||
'referer' => Request::header('referer'),
|
||||
'status_code' => $statusCode,
|
||||
]);
|
||||
|
||||
if (!$record->exists) {
|
||||
|
|
|
|||
|
|
@ -3,6 +3,10 @@
|
|||
# ===================================
|
||||
|
||||
columns:
|
||||
status_code:
|
||||
label: Status
|
||||
searchable: yes
|
||||
|
||||
url:
|
||||
label: URL
|
||||
searchable: yes
|
||||
|
|
|
|||
Loading…
Reference in New Issue