From 6308bc1ce00bc045c66342018a5031f3c5d74172 Mon Sep 17 00:00:00 2001 From: "Daniel S. Billing" Date: Tue, 21 Sep 2021 17:26:52 +0200 Subject: [PATCH] Added fortify and jetstream route files --- app/Providers/RouteServiceProvider.php | 6 + routes/fortify.php | 158 +++++++++++++++++++++++++ routes/jetstream.php | 40 +++++++ 3 files changed, 204 insertions(+) create mode 100644 routes/fortify.php create mode 100644 routes/jetstream.php diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index ca027ea..b130e6d 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -46,6 +46,12 @@ public function boot() Route::middleware('web') ->namespace($this->namespace) ->group(base_path('routes/web.php')); + + Route::namespace($this->namespace) + ->group(base_path('routes/jetstream.php')); + + Route::namespace($this->namespace) + ->group(base_path('routes/fortify.php')); }); } diff --git a/routes/fortify.php b/routes/fortify.php new file mode 100644 index 0000000..fa422b1 --- /dev/null +++ b/routes/fortify.php @@ -0,0 +1,158 @@ + config('fortify.middleware', ['web'])], function () { + $enableViews = config('fortify.views', true); + + // Authentication... + if ($enableViews) { + Route::get('/login', [AuthenticatedSessionController::class, 'create']) + ->middleware(['guest:'.config('fortify.guard')]) + ->name('login'); + } + + $limiter = config('fortify.limiters.login'); + $twoFactorLimiter = config('fortify.limiters.two-factor'); + + Route::post('/login', [AuthenticatedSessionController::class, 'store']) + ->middleware(array_filter([ + 'guest:'.config('fortify.guard'), + $limiter ? 'throttle:'.$limiter : null, + ])); + + Route::post('/logout', [AuthenticatedSessionController::class, 'destroy']) + ->name('logout'); + + // Password Reset... + if (Features::enabled(Features::resetPasswords())) { + if ($enableViews) { + Route::get('/forgot-password', [PasswordResetLinkController::class, 'create']) + ->middleware(['guest:'.config('fortify.guard')]) + ->name('password.request'); + + Route::get('/reset-password/{token}', [NewPasswordController::class, 'create']) + ->middleware(['guest:'.config('fortify.guard')]) + ->name('password.reset'); + } + + Route::post('/forgot-password', [PasswordResetLinkController::class, 'store']) + ->middleware(['guest:'.config('fortify.guard')]) + ->name('password.email'); + + Route::post('/reset-password', [NewPasswordController::class, 'store']) + ->middleware(['guest:'.config('fortify.guard')]) + ->name('password.update'); + } + + // Registration... + if (Features::enabled(Features::registration())) { + if ($enableViews) { + Route::get('/register', [RegisteredUserController::class, 'create']) + ->middleware(['guest:'.config('fortify.guard')]) + ->name('register'); + } + + Route::post('/register', [RegisteredUserController::class, 'store']) + ->middleware(['guest:'.config('fortify.guard')]); + } + + // Email Verification... + if (Features::enabled(Features::emailVerification())) { + if ($enableViews) { + Route::get('/email/verify', [EmailVerificationPromptController::class, '__invoke']) + ->middleware(['auth']) + ->name('verification.notice'); + } + + Route::get('/email/verify/{id}/{hash}', [VerifyEmailController::class, '__invoke']) + ->middleware(['auth', 'signed', 'throttle:6,1']) + ->name('verification.verify'); + + Route::post('/email/verification-notification', [EmailVerificationNotificationController::class, 'store']) + ->middleware(['auth', 'throttle:6,1']) + ->name('verification.send'); + } + + // Profile Information... + if (Features::enabled(Features::updateProfileInformation())) { + Route::put('/user/profile-information', [ProfileInformationController::class, 'update']) + ->middleware(['auth']) + ->name('user-profile-information.update'); + } + + // Passwords... + if (Features::enabled(Features::updatePasswords())) { + Route::put('/user/password', [PasswordController::class, 'update']) + ->middleware(['auth']) + ->name('user-password.update'); + } + + // Password Confirmation... + if ($enableViews) { + Route::get('/user/confirm-password', [ConfirmablePasswordController::class, 'show']) + ->middleware(['auth']) + ->name('password.confirm'); + } + + Route::get('/user/confirmed-password-status', [ConfirmedPasswordStatusController::class, 'show']) + ->middleware(['auth']) + ->name('password.confirmation'); + + Route::post('/user/confirm-password', [ConfirmablePasswordController::class, 'store']) + ->middleware(['auth']); + + // Two Factor Authentication... + if (Features::enabled(Features::twoFactorAuthentication())) { + if ($enableViews) { + Route::get('/two-factor-challenge', [TwoFactorAuthenticatedSessionController::class, 'create']) + ->middleware(['guest:'.config('fortify.guard')]) + ->name('two-factor.login'); + } + + Route::post('/two-factor-challenge', [TwoFactorAuthenticatedSessionController::class, 'store']) + ->middleware(array_filter([ + 'guest:'.config('fortify.guard'), + $twoFactorLimiter ? 'throttle:'.$twoFactorLimiter : null, + ])); + + $twoFactorMiddleware = Features::optionEnabled(Features::twoFactorAuthentication(), 'confirmPassword') + ? ['auth', 'password.confirm'] + : ['auth']; + + Route::post('/user/two-factor-authentication', [TwoFactorAuthenticationController::class, 'store']) + ->middleware($twoFactorMiddleware) + ->name('two-factor.enable'); + + Route::delete('/user/two-factor-authentication', [TwoFactorAuthenticationController::class, 'destroy']) + ->middleware($twoFactorMiddleware) + ->name('two-factor.disable'); + + Route::get('/user/two-factor-qr-code', [TwoFactorQrCodeController::class, 'show']) + ->middleware($twoFactorMiddleware) + ->name('two-factor.qr-code'); + + Route::get('/user/two-factor-recovery-codes', [RecoveryCodeController::class, 'index']) + ->middleware($twoFactorMiddleware) + ->name('two-factor.recovery-codes'); + + Route::post('/user/two-factor-recovery-codes', [RecoveryCodeController::class, 'store']) + ->middleware($twoFactorMiddleware); + } +}); diff --git a/routes/jetstream.php b/routes/jetstream.php new file mode 100644 index 0000000..8f3c681 --- /dev/null +++ b/routes/jetstream.php @@ -0,0 +1,40 @@ + config('jetstream.middleware', ['web'])], function () { + if (Jetstream::hasTermsAndPrivacyPolicyFeature()) { + Route::get('/terms', [TermsOfServiceController::class, 'show'])->name('terms.show'); + Route::get('/privacy', [PrivacyPolicyController::class, 'show'])->name('policy.show'); + } + + Route::group(['middleware' => ['auth', 'verified']], function () { + // User & Profile... + Route::get('/user/profile', [UserProfileController::class, 'show']) + ->name('profile.show'); + + // API... + if (Jetstream::hasApiFeatures()) { + Route::get('/user/api-tokens', [ApiTokenController::class, 'index'])->name('api-tokens.index'); + } + + // Teams... + if (Jetstream::hasTeamFeatures()) { + Route::get('/teams/create', [TeamController::class, 'create'])->name('teams.create'); + Route::get('/teams/{team}', [TeamController::class, 'show'])->name('teams.show'); + Route::put('/current-team', [CurrentTeamController::class, 'update'])->name('current-team.update'); + + Route::get('/team-invitations/{invitation}', [TeamInvitationController::class, 'accept']) + ->middleware(['signed']) + ->name('team-invitations.accept'); + } + }); +});