From 973eacf6c3f03ab27562a5a99af32a131f029f40 Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 24 Nov 2020 13:51:02 -0800 Subject: [PATCH] Small fixes for SAML MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The SAML routes are in a service provide (sigh), so they did not have the `web` middleware group assigned to it. I also added some additional checks so that the setup blade won’t fail (the migrations wouldn’t have been run yet, so outside of a try/catch, it would return an error since those tables don’t exist.) --- app/Http/Middleware/AssetCountForSidebar.php | 45 +++++++++++++++----- app/Providers/SamlServiceProvider.php | 2 +- resources/views/layouts/default.blade.php | 10 ++--- 3 files changed, 41 insertions(+), 16 deletions(-) diff --git a/app/Http/Middleware/AssetCountForSidebar.php b/app/Http/Middleware/AssetCountForSidebar.php index 123f6e82c5..ac14f8f8d2 100644 --- a/app/Http/Middleware/AssetCountForSidebar.php +++ b/app/Http/Middleware/AssetCountForSidebar.php @@ -17,16 +17,41 @@ class AssetCountForSidebar */ public function handle($request, Closure $next) { - $total_rtd_sidebar = Asset::RTD()->count(); - $total_deployed_sidebar = Asset::Deployed()->count(); - $total_archived_sidebar = Asset::Archived()->count(); - $total_pending_sidebar = Asset::Pending()->count(); - $total_undeployable_sidebar = Asset::Undeployable()->count(); - view()->share('total_rtd_sidebar', $total_rtd_sidebar); - view()->share('total_deployed_sidebar', $total_deployed_sidebar); - view()->share('total_archived_sidebar', $total_archived_sidebar); - view()->share('total_pending_sidebar', $total_pending_sidebar); - view()->share('total_undeployable_sidebar', $total_undeployable_sidebar); + try + { + $total_rtd_sidebar = Asset::RTD()->count(); + view()->share('total_rtd_sidebar', $total_rtd_sidebar); + } catch (\Exception $e) { + \Log::debug($e); + } + + try { + $total_deployed_sidebar = Asset::Deployed()->count(); + view()->share('total_deployed_sidebar', $total_deployed_sidebar); + } catch (\Exception $e) { + \Log::debug($e); + } + + try { + $total_archived_sidebar = Asset::Archived()->count(); + view()->share('total_archived_sidebar', $total_archived_sidebar); + } catch (\Exception $e) { + \Log::debug($e); + } + + try { + $total_pending_sidebar = Asset::Pending()->count(); + view()->share('total_pending_sidebar', $total_pending_sidebar); + } catch (\Exception $e) { + \Log::debug($e); + } + + try { + $total_undeployable_sidebar = Asset::Undeployable()->count(); + view()->share('total_undeployable_sidebar', $total_undeployable_sidebar); + } catch (\Exception $e) { + \Log::debug($e); + } return $next($request); } diff --git a/app/Providers/SamlServiceProvider.php b/app/Providers/SamlServiceProvider.php index edf40dd3d8..0caf0e77dd 100644 --- a/app/Providers/SamlServiceProvider.php +++ b/app/Providers/SamlServiceProvider.php @@ -49,7 +49,7 @@ class SamlServiceProvider extends ServiceProvider 'uses' => 'Auth\SamlController@login' ] ); - Route::group(['prefix' => 'admin','middleware' => ['auth', 'authorize:superuser']], function () { + Route::group(['prefix' => 'admin','middleware' => ['web','auth', 'authorize:superuser']], function () { Route::get('saml', ['as' => 'settings.saml.index','uses' => 'SettingsController@getSamlSettings' ]); Route::post('saml', ['as' => 'settings.saml.save','uses' => 'SettingsController@postSamlSettings' ]); diff --git a/resources/views/layouts/default.blade.php b/resources/views/layouts/default.blade.php index 9ccadc745d..77788b207c 100644 --- a/resources/views/layouts/default.blade.php +++ b/resources/views/layouts/default.blade.php @@ -422,7 +422,7 @@ {{ trans('general.all') }} {{ trans('general.deployed') }} - ({{ ($total_deployed_sidebar) ? $total_deployed_sidebar : '' }}) + ({{ (isset($total_deployed_sidebar)) ? $total_deployed_sidebar : '' }}) @@ -430,25 +430,25 @@ {{ trans('general.all') }} {{ trans('general.ready_to_deploy') }} - ({{ ($total_rtd_sidebar) ? $total_rtd_sidebar : '' }}) + ({{ (isset($total_rtd_sidebar)) ? $total_rtd_sidebar : '' }}) {{ trans('general.all') }} {{ trans('general.pending') }} - ({{ ($total_pending_sidebar) ? $total_pending_sidebar : '' }}) + ({{ (isset($total_pending_sidebar)) ? $total_pending_sidebar : '' }}) {{ trans('general.all') }} {{ trans('general.undeployable') }} - ({{ ($total_undeployable_sidebar) ? $total_undeployable_sidebar : '' }}) + ({{ (isset($total_undeployable_sidebar)) ? $total_undeployable_sidebar : '' }}) {{ trans('general.all') }} {{ trans('admin/hardware/general.archived') }} - ({{ ($total_archived_sidebar) ? $total_archived_sidebar : '' }}) + ({{ (isset($total_archived_sidebar)) ? $total_archived_sidebar : '' }})