Cleanup code and extra files

This commit is contained in:
DariusIII
2026-08-13 14:24:02 +02:00
parent aedfcf8737
commit 9af6ba1df5
7 changed files with 60 additions and 169 deletions
-81
View File
@@ -1,81 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Exceptions;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Session\TokenMismatchException;
use Spatie\Permission\Exceptions\UnauthorizedException;
use Symfony\Component\HttpFoundation\Response;
use Throwable;
class Handler extends ExceptionHandler
{
/**
* A list of the exception types that are not reported.
*
* @var array<int, class-string<Throwable>>
*/
protected $dontReport = [
//
];
/**
* A list of the inputs that are never flashed for validation exceptions.
*
* @var array<int, string>
*/
protected $dontFlash = [
'password',
'password_confirmation',
];
/**
* Catch errors with Sentry.
*/
public function register(): void
{
$this->reportable(function (Throwable $e) {
if (app()->bound('sentry')) {
app('sentry')->captureException($e);
}
});
}
/**
* Report or log an exception.
*
*
* @return void
*
* @throws Throwable
*/
public function report(Throwable $exception)
{
parent::report($exception);
}
/**
* @param Request $request
* @return RedirectResponse|Response
*
* @throws Throwable
*/
public function render($request, Throwable $exception)
{
if ($exception instanceof UnauthorizedException) {
abort(401);
}
if ($exception instanceof TokenMismatchException) {
return redirect()
->back()
->withInput($request->except(['password', 'password_confirmation']))
->with('error', 'The form has expired due to inactivity. Please refresh the page and try again');
}
return parent::render($request, $exception);
}
}
@@ -1,19 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode as Middleware;
class CheckForMaintenanceMode extends Middleware
{
/**
* The URIs that should be reachable while maintenance mode is enabled.
*
* @var array<int, string>
*/
protected $except = [
//
];
}
@@ -1,37 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Http\Middleware;
use Closure;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
class EnsureAuthenticatedUsersAreVerified
{
/**
* Handle an incoming request.
*
* @param Closure(Request): Response $next
*/
public function handle(Request $request, Closure $next, ?string $redirectToRoute = null): Response
{
$user = $request->user();
if ($user === null) {
return $next($request);
}
if ($user instanceof MustVerifyEmail && ! $user->hasVerifiedEmail()) {
if ($request->expectsJson()) {
abort(403, 'Your email address is not verified.');
}
return redirect()->route($redirectToRoute ?? 'verification.notice');
}
return $next($request);
}
}
-28
View File
@@ -1,28 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
class SetUserTimezone
{
/**
* Handle an incoming request.
*
* Note: We do NOT set the global timezone here because it would interfere
* with database operations and helper functions. Instead, the timezone
* conversion happens in the userDate() and userDateDiffForHumans() helpers.
*
* @param Closure(Request): (Response) $next
*/
public function handle(Request $request, Closure $next): Response
{
// Timezone conversion is handled by helper functions, not middleware
// This middleware is kept for future enhancements if needed
return $next($request);
}
}