- directory refactor (#32)

* - directory refactor

* - readme.md update

* Update readme.md

Co-authored-by: Adrian Hopek <adrian.hopek@blumilk.pl>

* Update readme.md

Co-authored-by: Ewelina Lasowy <56546832+EwelinaLasowy@users.noreply.github.com>

* Update readme.md

Co-authored-by: Ewelina Lasowy <56546832+EwelinaLasowy@users.noreply.github.com>

* Update readme.md

Co-authored-by: Ewelina Lasowy <56546832+EwelinaLasowy@users.noreply.github.com>

* Update readme.md

Co-authored-by: Adrian Hopek <adrian.hopek@blumilk.pl>
Co-authored-by: Ewelina Lasowy <56546832+EwelinaLasowy@users.noreply.github.com>
This commit is contained in:
Krzysztof Rewak
2022-01-26 12:31:26 +01:00
committed by GitHub
parent 026bfe485f
commit f6d59f8bfb
73 changed files with 214 additions and 217 deletions

View File

@@ -0,0 +1,15 @@
<?php
declare(strict_types=1);
namespace Toby\Infrastructure\Http\Middleware;
use Illuminate\Auth\Middleware\Authenticate as Middleware;
class Authenticate extends Middleware
{
protected function redirectTo($request): string
{
return route("login");
}
}

View File

@@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
namespace Toby\Infrastructure\Http\Middleware;
use Illuminate\Http\Request;
use Inertia\Middleware;
use Toby\Eloquent\Helpers\YearPeriodRetriever;
use Toby\Infrastructure\Http\Resources\UserResource;
class HandleInertiaRequests extends Middleware
{
public function __construct(
protected YearPeriodRetriever $yearPeriodRetriever,
) {
}
public function share(Request $request): array
{
$user = $request->user();
return array_merge(parent::share($request), [
"auth" => fn() => [
"user" => $user ? new UserResource($user) : null,
],
"flash" => fn() => [
"success" => $request->session()->get("success"),
"error" => $request->session()->get("error"),
],
"years" => fn() => $user ? $this->yearPeriodRetriever->links() : [],
]);
}
}

View File

@@ -0,0 +1,26 @@
<?php
declare(strict_types=1);
namespace Toby\Infrastructure\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Symfony\Component\HttpFoundation\Response;
class RedirectIfAuthenticated
{
public function handle(Request $request, Closure $next, ...$guards): Response
{
$guards = empty($guards) ? [null] : $guards;
foreach ($guards as $guard) {
if (Auth::guard($guard)->check()) {
return redirect()->route("dashboard");
}
}
return $next($request);
}
}

View File

@@ -0,0 +1,16 @@
<?php
declare(strict_types=1);
namespace Toby\Infrastructure\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
class TrimStrings extends Middleware
{
protected $except = [
"current_password",
"password",
"password_confirmation",
];
}

View File

@@ -0,0 +1,20 @@
<?php
declare(strict_types=1);
namespace Toby\Infrastructure\Http\Middleware;
use Illuminate\Http\Middleware\TrustProxies as Middleware;
use Symfony\Component\HttpFoundation\Request;
class TrustProxies extends Middleware
{
protected $proxies;
protected $headers =
Request::HEADER_X_FORWARDED_FOR |
Request::HEADER_X_FORWARDED_HOST |
Request::HEADER_X_FORWARDED_PORT |
Request::HEADER_X_FORWARDED_PROTO |
Request::HEADER_X_FORWARDED_AWS_ELB;
}