Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
asbiin committed Mar 27, 2024
1 parent f273f85 commit d6864c1
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 36 deletions.
3 changes: 1 addition & 2 deletions app/Http/Controllers/Auth/AuthenticatedSessionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use App\Http\Controllers\Controller;
use App\Http\Requests\Auth\LoginRequest;
use App\Providers\RouteServiceProvider;
use Illuminate\Contracts\View\View;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
Expand All @@ -29,7 +28,7 @@ public function store(LoginRequest $request): RedirectResponse

$request->session()->regenerate();

return redirect()->intended(RouteServiceProvider::HOME);
return redirect()->intended(route('home.index', absolute: false));
}

/**
Expand Down
3 changes: 1 addition & 2 deletions app/Http/Controllers/Auth/ConfirmablePasswordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Contracts\View\View;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
Expand Down Expand Up @@ -36,6 +35,6 @@ public function store(Request $request): RedirectResponse

$request->session()->put('auth.password_confirmed_at', time());

return redirect()->intended(RouteServiceProvider::HOME);
return redirect()->intended(route('home.index', absolute: false));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;

Expand All @@ -15,7 +14,7 @@ class EmailVerificationNotificationController extends Controller
public function store(Request $request): RedirectResponse
{
if ($request->user()->hasVerifiedEmail()) {
return redirect()->intended(RouteServiceProvider::HOME);
return redirect()->intended(route('home.index', absolute: false));
}

$request->user()->sendEmailVerificationNotification();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Contracts\View\View;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
Expand All @@ -16,7 +15,7 @@ class EmailVerificationPromptController extends Controller
public function __invoke(Request $request): RedirectResponse|View
{
return $request->user()->hasVerifiedEmail()
? redirect()->intended(RouteServiceProvider::HOME)
? redirect()->intended(route('home.index', absolute: false))
: view('auth.verify-email');
}
}
3 changes: 1 addition & 2 deletions app/Http/Controllers/Auth/RegisteredUserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use App\Http\Controllers\Controller;
use App\Models\User;
use App\Providers\RouteServiceProvider;
use App\Services\CreateAccount;
use Illuminate\Auth\Events\Registered;
use Illuminate\Contracts\View\View;
Expand Down Expand Up @@ -52,6 +51,6 @@ public function store(Request $request): RedirectResponse

Auth::login($user);

return redirect(RouteServiceProvider::HOME);
return redirect(route('home.index', absolute: false));
}
}
5 changes: 2 additions & 3 deletions app/Http/Controllers/Auth/VerifyEmailController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Auth\Events\Verified;
use Illuminate\Foundation\Auth\EmailVerificationRequest;
use Illuminate\Http\RedirectResponse;
Expand All @@ -16,13 +15,13 @@ class VerifyEmailController extends Controller
public function __invoke(EmailVerificationRequest $request): RedirectResponse
{
if ($request->user()->hasVerifiedEmail()) {
return redirect()->intended(RouteServiceProvider::HOME . '?verified=1');
return redirect()->intended(route('home.index', absolute: false) . '?verified=1');
}

if ($request->user()->markEmailAsVerified()) {
event(new Verified($request->user()));
}

return redirect()->intended(RouteServiceProvider::HOME . '?verified=1');
return redirect()->intended(route('home.index', absolute: false) . '?verified=1');
}
}
3 changes: 1 addition & 2 deletions app/Http/Middleware/RedirectIfAuthenticated.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace App\Http\Middleware;

use App\Providers\RouteServiceProvider;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
Expand All @@ -21,7 +20,7 @@ public function handle(Request $request, Closure $next, string ...$guards): Resp

foreach ($guards as $guard) {
if (Auth::guard($guard)->check()) {
return redirect(RouteServiceProvider::HOME);
return redirect(route('home.index', absolute: false));
}
}

Expand Down
10 changes: 5 additions & 5 deletions bootstrap/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
web: __DIR__ . '/../routes/web.php',
commands: __DIR__ . '/../routes/console.php',
api: __DIR__ . '/../routes/api.php',
apiPrefix: 'api',
health: '/up',
)
->withMiddleware(function (Middleware $middleware) {
$middleware->append(\Monicahq\Cloudflare\Http\Middleware\TrustProxies::class);
$middleware->replace(
\Illuminate\Http\Middleware\TrustProxies::class,
\Monicahq\Cloudflare\Http\Middleware\TrustProxies::class
);
$middleware->web(append: [
\Pirsch\Http\Middleware\TrackPageview::class,
]);
$middleware->api(prepend: [
\Illuminate\Routing\Middleware\ThrottleRequests::class . ':api',
]);
$middleware->throttleApi();
})
->withExceptions(function (Exceptions $exceptions) {
//
Expand Down
2 changes: 1 addition & 1 deletion routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider and all of them will
| routes are loaded by the bootstrap/app.php file and all of them will
| be assigned to the "api" middleware group. Make something great!
|
*/
Expand Down
21 changes: 12 additions & 9 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
use App\Http\Controllers\StoreNoteForNameInListController;
use App\Http\Controllers\TermsController;
use App\Http\Controllers\UserNameController;
use App\Http\Middleware\CheckLetter;
use App\Http\Middleware\CheckList;
use App\Http\Middleware\CheckName;
use Illuminate\Support\Facades\Route;

Route::get('partage/{uuid}', [ShareController::class, 'show'])->name('share.show');
Expand All @@ -35,19 +38,19 @@
Route::get('prenoms/filles', [FemaleNameController::class, 'index'])->name('name.fille.index');
Route::get('prenoms/mixtes', [MixteNameController::class, 'index'])->name('name.mixte.index');

Route::middleware(['letter'])->group(function (): void {
Route::get('prenoms/garcons/{letter}', [MaleNameController::class, 'letter'])->name('name.garcon.letter');
Route::get('prenoms/filles/{letter}', [FemaleNameController::class, 'letter'])->name('name.fille.letter');
Route::get('prenoms/mixtes/{letter}', [MixteNameController::class, 'letter'])->name('name.mixte.letter');
Route::get('prenoms/{letter}', [NameController::class, 'letter'])->name('name.letter');
Route::middleware([CheckLetter::class])->group(function (): void {
Route::get('prenoms/garcons/{letter}', [MaleNameController::class, 'letter'])->where('letter', '[A-Za-z]{1}')->name('name.garcon.letter');
Route::get('prenoms/filles/{letter}', [FemaleNameController::class, 'letter'])->where('letter', '[A-Za-z]{1}')->name('name.fille.letter');
Route::get('prenoms/mixtes/{letter}', [MixteNameController::class, 'letter'])->where('letter', '[A-Za-z]{1}')->name('name.mixte.letter');
Route::get('prenoms/{letter}', [NameController::class, 'letter'])->where('letter', '[A-Za-z]{1}')->name('name.letter');
});

Route::middleware(['name'])->group(function (): void {
Route::middleware([CheckName::class])->group(function (): void {
Route::get('prenoms/{id}/{name}', [NameController::class, 'show'])->name('name.show');
});

Route::middleware(['auth', 'verified'])->group(function (): void {
Route::middleware(['name'])->group(function (): void {
Route::middleware([CheckName::class])->group(function (): void {

// set favorites
// used in the list of names
Expand All @@ -68,7 +71,7 @@
Route::get('listes/nouveau', [ListController::class, 'new'])->name('list.new');
Route::post('listes', [ListController::class, 'store'])->name('list.store');

Route::middleware(['list'])->group(function (): void {
Route::middleware([CheckList::class])->group(function (): void {
Route::get('listes/{liste}/edition', [ListController::class, 'edit'])->name('list.edit');
Route::put('listes/{liste}', [ListController::class, 'update'])->name('list.update');
Route::get('listes/{liste}/suppression', [ListController::class, 'delete'])->name('list.delete');
Expand All @@ -92,7 +95,7 @@
Route::delete('profil', [ProfileController::class, 'destroy'])->name('profile.destroy');
});

Route::middleware(['list'])->group(function (): void {
Route::middleware([CheckList::class])->group(function (): void {
Route::get('listes/{liste}', [ListController::class, 'show'])->name('list.show');

Route::get('public/listes/{liste}', [PublicListController::class, 'show'])->name('list.public.show');
Expand Down
3 changes: 1 addition & 2 deletions tests/Feature/Auth/AuthenticationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Tests\Feature\Auth;

use App\Models\User;
use App\Providers\RouteServiceProvider;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;

Expand Down Expand Up @@ -34,7 +33,7 @@ public function users_can_authenticate_using_the_login_screen(): void
]);

$this->assertAuthenticated();
$response->assertRedirect(RouteServiceProvider::HOME);
$response->assertRedirect(route('home.index', absolute: false));
}

/**
Expand Down
3 changes: 1 addition & 2 deletions tests/Feature/Auth/EmailVerificationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Tests\Feature\Auth;

use App\Models\User;
use App\Providers\RouteServiceProvider;
use Illuminate\Auth\Events\Verified;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Event;
Expand Down Expand Up @@ -49,7 +48,7 @@ public function email_can_be_verified(): void

Event::assertDispatched(Verified::class);
$this->assertTrue($user->fresh()->hasVerifiedEmail());
$response->assertRedirect(RouteServiceProvider::HOME . '?verified=1');
$response->assertRedirect(route('home.index', absolute: false) . '?verified=1');
}

/**
Expand Down
3 changes: 1 addition & 2 deletions tests/Feature/Auth/RegistrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Tests\Feature\Auth;

use App\Providers\RouteServiceProvider;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;

Expand Down Expand Up @@ -32,6 +31,6 @@ public function new_users_can_register(): void
]);

$this->assertAuthenticated();
$response->assertRedirect(RouteServiceProvider::HOME);
$response->assertRedirect(route('home.index', absolute: false));
}
}

0 comments on commit d6864c1

Please sign in to comment.