Move Authlog to Laravel (#10559)
* Move Authlog to Laravel * Update authlog.blade.php
This commit is contained in:
parent
ac359bb377
commit
e4314922c1
|
@ -27,6 +27,7 @@ namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Http\Requests\StoreUserRequest;
|
use App\Http\Requests\StoreUserRequest;
|
||||||
use App\Http\Requests\UpdateUserRequest;
|
use App\Http\Requests\UpdateUserRequest;
|
||||||
|
use App\Models\AuthLog;
|
||||||
use App\Models\Dashboard;
|
use App\Models\Dashboard;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Models\UserPref;
|
use App\Models\UserPref;
|
||||||
|
@ -212,4 +213,13 @@ class UserController extends Controller
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function authlog()
|
||||||
|
{
|
||||||
|
$this->authorize('manage', User::class);
|
||||||
|
|
||||||
|
return view('user.authlog', [
|
||||||
|
'authlog' => AuthLog::orderBy('datetime', 'DESC')->get(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* AuthLog.php
|
||||||
|
*
|
||||||
|
* -Description-
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* @package LibreNMS
|
||||||
|
* @link http://librenms.org
|
||||||
|
* @copyright 2018 Tony Murray
|
||||||
|
* @author Tony Murray <murraytony@gmail.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class AuthLog extends Model
|
||||||
|
{
|
||||||
|
public $timestamps = false;
|
||||||
|
protected $table = 'authlog';
|
||||||
|
protected $dates = ['datetime'];
|
||||||
|
}
|
|
@ -1,42 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
echo "<h3>Authlog</h3>";
|
|
||||||
if (Auth::user()->hasGlobalAdmin()) {
|
|
||||||
echo '<table id="authlogtable" class="table table-hover table-condensed">';
|
|
||||||
echo "<thead><th data-column-id='timestamp'>Timestamp</th><th data-column-id='user'>User</th><th data-column-id='ip'>IP Address</th><th data-column-id='authres'>Result</th></thead><tbody>";
|
|
||||||
foreach (dbFetchRows("SELECT *,DATE_FORMAT(datetime, '" . \LibreNMS\Config::get('dateformat.mysql.compact') . "') as humandate FROM `authlog` ORDER BY `datetime` DESC LIMIT 0,250") as $entry) {
|
|
||||||
if ($bg == \LibreNMS\Config::get('list_colour.even')) {
|
|
||||||
$bg = \LibreNMS\Config::get('list_colour.odd');
|
|
||||||
} else {
|
|
||||||
$bg = \LibreNMS\Config::get('list_colour.even');
|
|
||||||
}
|
|
||||||
|
|
||||||
echo "<tr>
|
|
||||||
<td>
|
|
||||||
".$entry['datetime'].'
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
'.$entry['user'].'
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
'.$entry['address'].'
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
'.$entry['result'].'
|
|
||||||
</td>
|
|
||||||
';
|
|
||||||
}//end foreach
|
|
||||||
|
|
||||||
$pagetitle[] = 'Authlog';
|
|
||||||
|
|
||||||
echo '</tbody></table>';
|
|
||||||
} else {
|
|
||||||
include 'includes/html/error-no-perm.inc.php';
|
|
||||||
}//end if
|
|
||||||
?>
|
|
||||||
<script>
|
|
||||||
$('#authlogtable').bootgrid({
|
|
||||||
rowCount: [50, 100, 250, -1],
|
|
||||||
columnSelection: true,
|
|
||||||
});
|
|
||||||
</script>
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
@extends('layouts.librenmsv1')
|
||||||
|
|
||||||
|
@section('title', __('Authlog'))
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<div class="container-fluid">
|
||||||
|
<div id="manage-authlog-panel" class="panel panel-default">
|
||||||
|
<div class="panel-heading">
|
||||||
|
<h4 class="panel-title"><i class="fa fa-user-circle-o fa-fw fa-lg" aria-hidden="true"></i> @lang('Authlog')</h4>
|
||||||
|
</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table id="authlog" class="table table-hover table-condensed table-striped" style="display: none;">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th data-column-id='timestamp'>@lang('Timestamp')</th>
|
||||||
|
<th data-column-id='user'>@lang('User')</th>
|
||||||
|
<th data-column-id='ip'>@lang('IP Address')</th>
|
||||||
|
<th data-column-id='authres'>@lang('Result')</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody id="authlog_rows">
|
||||||
|
@foreach($authlog as $log)
|
||||||
|
<tr>
|
||||||
|
<td>{{ $log->datetime }}</td>
|
||||||
|
<td>{{ $log->user }}</td>
|
||||||
|
<td>{{ $log->address }}</td>
|
||||||
|
<td>{{ $log->result }}</td>
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section('scripts')
|
||||||
|
<script>
|
||||||
|
var authlog_grid = $("#authlog");
|
||||||
|
authlog_grid.bootgrid();
|
||||||
|
authlog_grid.css('display', 'table'); // done loading, show
|
||||||
|
</script>
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section('css')
|
||||||
|
<style>
|
||||||
|
#manage-authlog-panel .panel-title { font-size: 18px; }
|
||||||
|
</style>
|
||||||
|
@endsection
|
|
@ -27,6 +27,7 @@ Route::group(['middleware' => ['auth', '2fa'], 'guard' => 'auth'], function () {
|
||||||
Route::resource('preferences', 'UserPreferencesController', ['only' => ['index', 'store']]);
|
Route::resource('preferences', 'UserPreferencesController', ['only' => ['index', 'store']]);
|
||||||
Route::resource('users', 'UserController');
|
Route::resource('users', 'UserController');
|
||||||
Route::get('about', 'AboutController@index');
|
Route::get('about', 'AboutController@index');
|
||||||
|
Route::get('authlog', 'UserController@authlog');
|
||||||
|
|
||||||
// old route redirects
|
// old route redirects
|
||||||
Route::permanentRedirect('poll-log', 'pollers/tab=log/');
|
Route::permanentRedirect('poll-log', 'pollers/tab=log/');
|
||||||
|
|
Loading…
Reference in New Issue