This commit is contained in:
Kekskurse 2021-02-08 00:11:09 +01:00
parent 3662c7465a
commit dc778921c1
4 changed files with 33 additions and 4 deletions

View file

@ -2,6 +2,7 @@
namespace App\Http;
use App\Http\Middleware\AuthMiddleware;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
class Kernel extends HttpKernel
@ -39,6 +40,10 @@ class Kernel extends HttpKernel
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
'auth' => [
AuthMiddleware::class
],
'api' => [
'throttle:api',
\Illuminate\Routing\Middleware\SubstituteBindings::class,

View file

@ -0,0 +1,27 @@
<?php
namespace App\Http\Middleware;
use App\Models\Tenant;
use Closure;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Log;
class AuthMiddleware
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if(Auth::check()) {
return redirect("/login");
}
return $next($request);
}
}

View file

@ -5,7 +5,6 @@
@section('content')
<div class="row" style="margin-top: 20px;">
<div class="col-md-12">
@foreach($galleries as $gallery)
<div class="row" style="margin-bottom: 20px;border-bottom: 1px solid grey;padding-bottom: 20px;">
<div class="col-md-4">
@ -19,9 +18,7 @@
<img src="/{{$tenant->url}}/{{$gallery->url}}/{{$gallery->main_image}}/file?size=big" style="width: 100%;">
</div>
</div>
@endforeach
</div>
</div>

View file

@ -27,7 +27,7 @@ Route::post("/register", [\App\Http\Controllers\AccountController::class, 'regis
Route::get("/login", [\App\Http\Controllers\AccountController::class, 'loginView']);
Route::post("/login", [\App\Http\Controllers\AccountController::class, 'login']);
Route::middleware([\App\Http\Middleware\TenanMiddleware::class])->group(function () {
Route::middleware([\App\Http\Middleware\TenanMiddleware::class, \App\Http\Middleware\AuthMiddleware::class])->group(function () {
Route::get("/d", [\App\Http\Controllers\DashboardController::class, 'dashboardView']);
Route::get("/t/new", [\App\Http\Controllers\TenantController::class, 'newView']);