mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-04-18 14:38:52 +02:00
Fix ScanForNewRelease event triggering whereas checkForUpdate is disabled - Fixes #462
This commit is contained in:
parent
fc7ca1448c
commit
f6a595807d
@ -5,7 +5,6 @@
|
|||||||
use App\Events\ScanForNewReleaseCalled;
|
use App\Events\ScanForNewReleaseCalled;
|
||||||
use App\Facades\Settings;
|
use App\Facades\Settings;
|
||||||
use Illuminate\Support\Facades\App;
|
use Illuminate\Support\Facades\App;
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
use Illuminate\Support\Facades\Vite;
|
use Illuminate\Support\Facades\Vite;
|
||||||
|
|
||||||
class SinglePageController extends Controller
|
class SinglePageController extends Controller
|
||||||
@ -17,12 +16,15 @@ class SinglePageController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
event(new ScanForNewReleaseCalled);
|
$appSettings = Settings::all();
|
||||||
|
|
||||||
|
if ($appSettings['checkForUpdate'] == true) {
|
||||||
|
event(new ScanForNewReleaseCalled);
|
||||||
|
}
|
||||||
|
|
||||||
// We only share necessary and acceptable values with the HTML front-end.
|
// We only share necessary and acceptable values with the HTML front-end.
|
||||||
// But all the properties have to be pushed to init the appSetting store state correctly,
|
// But all the properties have to be pushed to init the appSetting store state correctly,
|
||||||
// so we set them to null, they will be fed later by the front-end
|
// so we set them to null, they will be fed later by the front-end
|
||||||
$appSettings = Settings::all();
|
|
||||||
$publicSettings = $appSettings->only([
|
$publicSettings = $appSettings->only([
|
||||||
'disableRegistration',
|
'disableRegistration',
|
||||||
'enableSso',
|
'enableSso',
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
namespace Tests\Feature;
|
namespace Tests\Feature;
|
||||||
|
|
||||||
use App\Events\ScanForNewReleaseCalled;
|
use App\Events\ScanForNewReleaseCalled;
|
||||||
|
use App\Facades\Settings;
|
||||||
use App\Http\Controllers\SinglePageController;
|
use App\Http\Controllers\SinglePageController;
|
||||||
use Illuminate\Support\Facades\Event;
|
use Illuminate\Support\Facades\Event;
|
||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
@ -60,4 +61,15 @@ public function test_calling_index_fires_ScanForNewReleaseCalled_event()
|
|||||||
|
|
||||||
Event::assertDispatched(ScanForNewReleaseCalled::class);
|
Event::assertDispatched(ScanForNewReleaseCalled::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[Test]
|
||||||
|
public function test_calling_index_does_not_fire_ScanForNewReleaseCalled_event()
|
||||||
|
{
|
||||||
|
Event::fake();
|
||||||
|
Settings::set('checkForUpdate', false);
|
||||||
|
|
||||||
|
$this->get('/');
|
||||||
|
|
||||||
|
Event::assertNotDispatched(ScanForNewReleaseCalled::class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user