diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index d46c485086..422f3dbae5 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -23,10 +23,10 @@ use Illuminate\Foundation\Auth\Access\AuthorizesRequests; use Illuminate\Foundation\Bus\DispatchesJobs; use Illuminate\Foundation\Validation\ValidatesRequests; use Illuminate\Routing\Controller as BaseController; +use Route; use Session; use URL; use View; -use Route; /** * Class Controller @@ -66,10 +66,12 @@ class Controller extends BaseController $this->dateTimeFormat = (string)trans('config.date_time'); // get shown-intro-preference: - $key = 'shown_demo_' . Route::currentRouteName(); - $shownDemo = Preferences::get($key, false)->data; - View::share('shownDemo', $shownDemo); - View::share('current_route_name', Route::currentRouteName()); + if (auth()->check()) { + $key = 'shown_demo_' . Route::currentRouteName(); + $shownDemo = Preferences::get($key, false)->data; + View::share('shownDemo', $shownDemo); + View::share('current_route_name', Route::currentRouteName()); + } return $next($request); } diff --git a/app/Models/Account.php b/app/Models/Account.php index f6b4481c1d..26ab5424a5 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -116,7 +116,7 @@ class Account extends Model { if (auth()->check()) { - if ($value->user_id === auth()->user()->id) { + if (intval($value->user_id) === auth()->user()->id) { return $value; } } diff --git a/app/Models/Attachment.php b/app/Models/Attachment.php index ce8eeec9fc..bc9fd231f7 100644 --- a/app/Models/Attachment.php +++ b/app/Models/Attachment.php @@ -55,7 +55,7 @@ class Attachment extends Model { if (auth()->check()) { - if ($value->user_id === auth()->user()->id) { + if (intval($value->user_id) === auth()->user()->id) { return $value; } } diff --git a/app/Models/Bill.php b/app/Models/Bill.php index d879cbd8d3..8659be7749 100644 --- a/app/Models/Bill.php +++ b/app/Models/Bill.php @@ -62,7 +62,7 @@ class Bill extends Model public static function routeBinder(Bill $value) { if (auth()->check()) { - if ($value->user_id === auth()->user()->id) { + if (intval($value->user_id) === auth()->user()->id) { return $value; } } diff --git a/app/Models/Budget.php b/app/Models/Budget.php index cbbaafab24..6f1a5f3386 100644 --- a/app/Models/Budget.php +++ b/app/Models/Budget.php @@ -85,7 +85,7 @@ class Budget extends Model public static function routeBinder(Budget $value) { if (auth()->check()) { - if ($value->user_id === auth()->user()->id) { + if (intval($value->user_id) === auth()->user()->id) { return $value; } } diff --git a/app/Models/Category.php b/app/Models/Category.php index e10e384d35..85894a271a 100644 --- a/app/Models/Category.php +++ b/app/Models/Category.php @@ -86,7 +86,7 @@ class Category extends Model public static function routeBinder(Category $value) { if (auth()->check()) { - if ($value->user_id === auth()->user()->id) { + if (intval($value->user_id) === auth()->user()->id) { return $value; } } diff --git a/app/Models/Rule.php b/app/Models/Rule.php index 59d572c424..e8f334167b 100644 --- a/app/Models/Rule.php +++ b/app/Models/Rule.php @@ -51,7 +51,7 @@ class Rule extends Model public static function routeBinder(Rule $value) { if (auth()->check()) { - if ($value->user_id === auth()->user()->id) { + if (intval($value->user_id) === auth()->user()->id) { return $value; } } diff --git a/app/Models/RuleGroup.php b/app/Models/RuleGroup.php index 1b62d9a1fe..98ac15354b 100644 --- a/app/Models/RuleGroup.php +++ b/app/Models/RuleGroup.php @@ -52,7 +52,7 @@ class RuleGroup extends Model public static function routeBinder(RuleGroup $value) { if (auth()->check()) { - if ($value->user_id === auth()->user()->id) { + if (intval($value->user_id) === auth()->user()->id) { return $value; } } diff --git a/app/Models/Tag.php b/app/Models/Tag.php index 4ac3c24356..c7a67e4f6a 100644 --- a/app/Models/Tag.php +++ b/app/Models/Tag.php @@ -87,7 +87,7 @@ class Tag extends Model public static function routeBinder(Tag $value) { if (auth()->check()) { - if ($value->user_id === auth()->user()->id) { + if (intval($value->user_id) === auth()->user()->id) { return $value; } } diff --git a/config/twigbridge.php b/config/twigbridge.php index 095c342c9c..b6470423d3 100644 --- a/config/twigbridge.php +++ b/config/twigbridge.php @@ -156,6 +156,7 @@ return [ 'Preferences', 'URL', 'Config', + 'Request', 'ExpandedForm' => [ 'is_safe' => [ 'date', 'text', 'select', 'balance', 'optionsList', 'checkbox', 'amount', 'tags', 'integer', 'textarea', 'location', diff --git a/resources/views/errors/404.twig b/resources/views/errors/404.twig index d84ff35ca6..73b145622f 100644 --- a/resources/views/errors/404.twig +++ b/resources/views/errors/404.twig @@ -30,6 +30,8 @@
The page you have requested does not exist. Please check that you have not entered the wrong URL. Did you make a typo perhaps? + +
diff --git a/tests/Feature/Controllers/Auth/TwoFactorControllerTest.php b/tests/Feature/Controllers/Auth/TwoFactorControllerTest.php index 5c268d3560..feed6fb66e 100644 --- a/tests/Feature/Controllers/Auth/TwoFactorControllerTest.php +++ b/tests/Feature/Controllers/Auth/TwoFactorControllerTest.php @@ -35,9 +35,16 @@ class TwoFactorControllerTest extends TestCase $truePref->data = true; $secretPreference = new Preference; $secretPreference->data = 'BlablaSeecret'; + + Preferences::shouldReceive('get')->withArgs(['twoFactorAuthEnabled', false])->andReturn($truePref)->twice(); Preferences::shouldReceive('get')->withArgs(['twoFactorAuthSecret', null])->andReturn($secretPreference)->once(); Preferences::shouldReceive('get')->withArgs(['twoFactorAuthSecret'])->andReturn($secretPreference)->once(); + + $falsePref = new Preference; + $falsePref->data = false; + Preferences::shouldReceive('get')->withArgs(['shown_demo_two-factor.index', false])->andReturn($falsePref)->once(); + $response = $this->get(route('two-factor.index')); $response->assertStatus(200); } @@ -54,6 +61,8 @@ class TwoFactorControllerTest extends TestCase Preferences::shouldReceive('get')->withArgs(['twoFactorAuthEnabled', false])->andReturn($falsePreference)->twice(); Preferences::shouldReceive('get')->withArgs(['twoFactorAuthSecret', null])->andReturn(null)->once(); Preferences::shouldReceive('get')->withArgs(['twoFactorAuthSecret'])->andReturn(null)->once(); + Preferences::shouldReceive('get')->withArgs(['shown_demo_two-factor.index', false])->andReturn($falsePreference)->once(); + $response = $this->get(route('two-factor.index')); $response->assertStatus(302); $response->assertRedirect(route('index')); @@ -74,6 +83,11 @@ class TwoFactorControllerTest extends TestCase Preferences::shouldReceive('get')->withArgs(['twoFactorAuthEnabled', false])->andReturn($truePref)->twice(); Preferences::shouldReceive('get')->withArgs(['twoFactorAuthSecret', null])->andReturn($secretPreference)->once(); Preferences::shouldReceive('get')->withArgs(['twoFactorAuthSecret'])->andReturn($secretPreference)->once(); + + $falsePref = new Preference; + $falsePref->data = false; + Preferences::shouldReceive('get')->withArgs(['shown_demo_two-factor.index', false])->andReturn($falsePref)->once(); + $response = $this->get(route('two-factor.index')); $response->assertStatus(500); } @@ -92,6 +106,11 @@ class TwoFactorControllerTest extends TestCase Preferences::shouldReceive('get')->withArgs(['twoFactorAuthEnabled', false])->andReturn($truePreference); Preferences::shouldReceive('get')->withArgs(['twoFactorAuthSecret', null])->andReturn($secretPreference); Preferences::shouldReceive('get')->withArgs(['twoFactorAuthSecret'])->andReturn($secretPreference); + + $falsePref = new Preference; + $falsePref->data = false; + Preferences::shouldReceive('get')->withArgs(['shown_demo_two-factor.lost', false])->andReturn($falsePref)->once(); + $response = $this->get(route('two-factor.lost')); $response->assertStatus(200); }