Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
27pchrisl committed Oct 31, 2020
1 parent c8328da commit f4ed0cc
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/Facades/Lodata.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Flat3\Lodata\Interfaces\Operation\FunctionInterface;
use Flat3\Lodata\Interfaces\ResourceInterface;
use Flat3\Lodata\Interfaces\ServiceInterface;
use Flat3\Lodata\Model;
use Flat3\Lodata\Operation;
use Flat3\Lodata\Singleton;
use Illuminate\Support\Facades\Facade;
Expand Down Expand Up @@ -40,6 +41,6 @@ class Lodata extends Facade
{
protected static function getFacadeAccessor()
{
return 'lodata.model';
return Model::class;
}
}
2 changes: 1 addition & 1 deletion src/Helper/Gate.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static function check(
$gate->transaction = $transaction;
$gate->arguments = $arguments;

if (ServiceProvider::usingPreview()) {
if (ServiceProvider::hasDisabledAuth()) {
return;
}

Expand Down
10 changes: 7 additions & 3 deletions src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,17 @@ public function register()
$this->mergeConfigFrom(__DIR__.'/../config.php', 'lodata');
}

public static function usingPreview(): bool
public static function hasDisabledAuth(): bool
{
return env('LODATA_PREVIEW', false);
return env('LODATA_DISABLE_AUTH', false);
}

public function boot()
{
if ($this->app->runningInConsole()) {
$this->publishes([__DIR__.'/../config.php' => config_path('lodata.php')], 'config');
}

$this->app->singleton(Model::class, function () {
return new Model();
});
Expand All @@ -42,7 +46,7 @@ public function boot()

$middleware = config('lodata.middleware', []);

if (self::usingPreview()) {
if (self::hasDisabledAuth()) {
$middleware = [];
}

Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Protocol/PreviewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class PreviewTest extends TestCase
{
public function setUp(): void
{
Env::getRepository()->set('LODATA_PREVIEW', 1);
Env::getRepository()->set('LODATA_DISABLE_AUTH', 1);
parent::setUp();
$this->gateMock->andReturnFalse();
$this->withFlightModel();
Expand All @@ -19,7 +19,7 @@ public function setUp(): void
public function tearDown(): void
{
parent::tearDown();
Env::getRepository()->clear('LODATA_PREVIEW');
Env::getRepository()->clear('LODATA_DISABLE_AUTH');
}

public function test_disables_auth()
Expand Down

0 comments on commit f4ed0cc

Please sign in to comment.