separate checking installation as a middleware
This commit is contained in:
parent
294b008880
commit
13e51464f6
|
|
@ -18,31 +18,18 @@ class SetupController extends Controller
|
|||
{
|
||||
public function welcome()
|
||||
{
|
||||
// already installed
|
||||
if (self::checkTablesExist()) {
|
||||
return view('setup.locked');
|
||||
} else {
|
||||
$config = config('database.connections.mysql');
|
||||
$config = config('database.connections.mysql');
|
||||
|
||||
return view('setup.wizard.welcome')->with('server', "{$config['username']}@{$config['host']}");
|
||||
}
|
||||
return view('setup.wizard.welcome')->with('server', "{$config['username']}@{$config['host']}");
|
||||
}
|
||||
|
||||
public function info()
|
||||
{
|
||||
if (self::checkTablesExist()) {
|
||||
return view('setup.locked');
|
||||
}
|
||||
|
||||
return view('setup.wizard.info');
|
||||
}
|
||||
|
||||
public function finish(Request $request)
|
||||
{
|
||||
if (self::checkTablesExist()) {
|
||||
return view('setup.locked');
|
||||
}
|
||||
|
||||
$this->validate($request, [
|
||||
'email' => 'required|email',
|
||||
'password' => 'required|min:6|max:16|confirmed',
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ class Kernel extends HttpKernel
|
|||
'auth' => \App\Http\Middleware\CheckAuthenticated::class,
|
||||
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
|
||||
'admin' => \App\Http\Middleware\CheckAdministrator::class,
|
||||
'player' => \App\Http\Middleware\CheckPlayerExist::class
|
||||
'player' => \App\Http\Middleware\CheckPlayerExist::class,
|
||||
'setup' => \App\Http\Middleware\CheckInstallation::class,
|
||||
];
|
||||
}
|
||||
|
|
|
|||
17
app/Http/Middleware/CheckInstallation.php
Normal file
17
app/Http/Middleware/CheckInstallation.php
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Http\Controllers\SetupController;
|
||||
|
||||
class CheckInstallation
|
||||
{
|
||||
public function handle($request, \Closure $next)
|
||||
{
|
||||
if (SetupController::checkTablesExist()) {
|
||||
return response()->view('setup.locked');
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
|
|
@ -16,9 +16,11 @@
|
|||
*/
|
||||
Route::group(['prefix' => 'setup'], function ()
|
||||
{
|
||||
Route::get ('/', 'SetupController@welcome');
|
||||
Route::get ('/info', 'SetupController@info');
|
||||
Route::post('/finish', 'SetupController@finish');
|
||||
Route::group(['middleware' => 'setup'], function () {
|
||||
Route::get ('/', 'SetupController@welcome');
|
||||
Route::get ('/info', 'SetupController@info');
|
||||
Route::post('/finish', 'SetupController@finish');
|
||||
});
|
||||
|
||||
Route::get ('/update', 'SetupController@update');
|
||||
Route::post('/update', 'SetupController@doUpdate');
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user