Files
librenms-librenms/app/Http/Middleware/CheckInstalled.php
Tony Murray 5f0388f0e3 Remove DB credentials from config.php
Better validation when config.php does not exist

Update docs and quote password

only populate legacy vars in config_to_json
drop .travis.yml config copy
remove credentials from config.php.default

Check for existance of .env instead of config.php in python scripts

legacy credential cleanup

tiny cleanups

consistent env for artisan server and artisan dusk
2020-06-27 07:47:08 -05:00

55 lines
1.7 KiB
PHP

<?php
/**
* CheckInstalled.php
*
* Check if LibreNMS install has been completed (config.php exists) and redirect to install.php as needed.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2018 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace App\Http\Middleware;
use Closure;
use Illuminate\Auth\Access\AuthorizationException;
class CheckInstalled
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$installed = !config('librenms.install') && file_exists(base_path('.env'));
$is_install_route = $request->is('install*');
if (!$installed && !$is_install_route) {
// no config.php does so let's redirect to the install
return redirect()->route('install');
} elseif ($installed && $is_install_route) {
throw new AuthorizationException('This should only be called during install');
}
return $next($request);
}
}