Introduce HasSettingFilter that'll redirect to setup
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
Route::filter('is_setup', 'IsSetupFilter');
|
||||
Route::filter('has_setting', 'HasSettingFilter');
|
||||
Route::filter('cors', 'CORSFilter');
|
||||
|
||||
/*
|
||||
|
||||
14
app/filters/HasSettingFilter.php
Normal file
14
app/filters/HasSettingFilter.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
class HasSettingFilter {
|
||||
public function filter($route, $request, $settingName) {
|
||||
try {
|
||||
$setting = Setting::where('name', $settingName)->first();
|
||||
if (!$setting->value) {
|
||||
return Redirect::to('setup');
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
return Redirect::to('setup');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,13 @@
|
||||
<?php
|
||||
|
||||
Route::get('/', 'HomeController@showIndex');
|
||||
Route::get('/incident/{incident}', 'HomeController@showIncident');
|
||||
// Prevent access until the app is setup.
|
||||
Route::group(['before' => 'has_setting:app_name'], function() {
|
||||
Route::get('/', 'HomeController@showIndex');
|
||||
Route::get('/incident/{incident}', 'HomeController@showIncident');
|
||||
|
||||
Route::get('/auth/login', 'AuthController@showLogin')->before('guest');
|
||||
Route::post('/auth/login', 'AuthController@postLogin')->before('guest|csrf');
|
||||
});
|
||||
|
||||
Route::group(['before' => 'no_setup:app_name'], function() {
|
||||
Route::get('/setup', 'SetupController@showSetup');
|
||||
@@ -10,9 +16,6 @@ Route::group(['before' => 'no_setup:app_name'], function() {
|
||||
});
|
||||
});
|
||||
|
||||
Route::get('/auth/login', 'AuthController@showLogin')->before('guest');
|
||||
Route::post('/auth/login', 'AuthController@postLogin')->before('guest|csrf');
|
||||
|
||||
Route::group(['before' => 'auth'], function() {
|
||||
// Dashboard/Management Panel etc.
|
||||
Route::get('/dashboard', 'DashboardController@showDashboard');
|
||||
|
||||
Reference in New Issue
Block a user