mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-08-26 20:22:18 +00:00
Merge branch 'search-by-ip' of https://github.com/johnroyer/BookStack into johnroyer-search-by-ip
This commit is contained in:
commit
5c04f25c86
@ -20,6 +20,7 @@ class AuditLogController extends Controller
|
|||||||
'date_from' => $request->get('date_from', ''),
|
'date_from' => $request->get('date_from', ''),
|
||||||
'date_to' => $request->get('date_to', ''),
|
'date_to' => $request->get('date_to', ''),
|
||||||
'user' => $request->get('user', ''),
|
'user' => $request->get('user', ''),
|
||||||
|
'ip' => $request->get('ip', ''),
|
||||||
];
|
];
|
||||||
|
|
||||||
$query = Activity::query()
|
$query = Activity::query()
|
||||||
@ -44,6 +45,9 @@ class AuditLogController extends Controller
|
|||||||
if ($listDetails['date_to']) {
|
if ($listDetails['date_to']) {
|
||||||
$query->where('created_at', '<=', $listDetails['date_to']);
|
$query->where('created_at', '<=', $listDetails['date_to']);
|
||||||
}
|
}
|
||||||
|
if ($listDetails['ip']) {
|
||||||
|
$query->where('ip', 'like', $listDetails['ip'] . '%');
|
||||||
|
}
|
||||||
|
|
||||||
$activities = $query->paginate(100);
|
$activities = $query->paginate(100);
|
||||||
$activities->appends($listDetails);
|
$activities->appends($listDetails);
|
||||||
|
@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class AddIndexForUserIp extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('activities', function (Blueprint $table) {
|
||||||
|
$table->index('ip', 'activities_ip_index');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('activities', function (Blueprint $table) {
|
||||||
|
$table->dropIndex('activities_ip_index');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -41,12 +41,19 @@
|
|||||||
</div>
|
</div>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
|
||||||
<div class="form-group ml-auto"
|
<div class="form-group ml-auto mr-m"
|
||||||
component="submit-on-change"
|
component="submit-on-change"
|
||||||
option:submit-on-change:filter='[name="user"]'>
|
option:submit-on-change:filter='[name="user"]'>
|
||||||
<label for="owner">{{ trans('settings.audit_table_user') }}</label>
|
<label for="owner">{{ trans('settings.audit_table_user') }}</label>
|
||||||
@include('form.user-select', ['user' => $listDetails['user'] ? \BookStack\Auth\User::query()->find($listDetails['user']) : null, 'name' => 'user', 'compact' => true])
|
@include('form.user-select', ['user' => $listDetails['user'] ? \BookStack\Auth\User::query()->find($listDetails['user']) : null, 'name' => 'user', 'compact' => true])
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="form-group ml-auto">
|
||||||
|
<label for="ip">{{ trans('settings.audit_table_ip') }}</label>
|
||||||
|
@include('form.text', ['name' => 'ip', 'model' => (object) $listDetails])
|
||||||
|
<input type="submit" style="display: none">
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -166,6 +166,24 @@ class AuditLogTest extends TestCase
|
|||||||
$resp->assertSee('192.123.45.1');
|
$resp->assertSee('192.123.45.1');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_ip_address_is_searchable()
|
||||||
|
{
|
||||||
|
config()->set('app.proxies', '*');
|
||||||
|
$editor = $this->getEditor();
|
||||||
|
/** @var Page $page */
|
||||||
|
$page = Page::query()->first();
|
||||||
|
|
||||||
|
$this->actingAs($editor)->put($page->getUrl(), [
|
||||||
|
'name' => 'Updated page',
|
||||||
|
'html' => '<p>Updated content</p>',
|
||||||
|
], [
|
||||||
|
'X-Forwarded-For' => '192.123.45.1',
|
||||||
|
])->assertRedirect($page->refresh()->getUrl());
|
||||||
|
|
||||||
|
$resp = $this->asAdmin()->get('/settings/audit?&ip=192.123');
|
||||||
|
$resp->assertSee('192.123.45.1');
|
||||||
|
}
|
||||||
|
|
||||||
public function test_ip_address_not_logged_in_demo_mode()
|
public function test_ip_address_not_logged_in_demo_mode()
|
||||||
{
|
{
|
||||||
config()->set('app.proxies', '*');
|
config()->set('app.proxies', '*');
|
||||||
|
Loading…
Reference in New Issue
Block a user