Skip to content

Commit

Permalink
[1.x] Add disable_views configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandrebordiere committed Oct 31, 2020
1 parent a0cb3e7 commit 31874d0
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 30 deletions.
1 change: 1 addition & 0 deletions config/fortify.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
'passwords' => 'users',
'username' => 'email',
'email' => 'email',
'disable_views' => false,
'home' => '/home',
'limiters' => [
'login' => null,
Expand Down
76 changes: 46 additions & 30 deletions routes/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@
use Laravel\Fortify\Http\Controllers\VerifyEmailController;

Route::group(['middleware' => config('fortify.middleware', ['web'])], function () {
$disableViews = config('fortify.disable_views');

// Authentication...
Route::get('/login', [AuthenticatedSessionController::class, 'create'])
->middleware(['guest'])
->name('login');
if (! $disableViews) {
Route::get('/login', [AuthenticatedSessionController::class, 'create'])
->middleware(['guest'])
->name('login');
}

$limiter = config('fortify.limiters.login');

Expand All @@ -37,38 +41,44 @@

// Password Reset...
if (Features::enabled(Features::resetPasswords())) {
Route::get('/forgot-password', [PasswordResetLinkController::class, 'create'])
->middleware(['guest'])
->name('password.request');
if (! $disableViews) {
Route::get('/forgot-password', [PasswordResetLinkController::class, 'create'])
->middleware(['guest'])
->name('password.request');

Route::get('/reset-password/{token}', [NewPasswordController::class, 'create'])
->middleware(['guest'])
->name('password.reset');
}

Route::post('/forgot-password', [PasswordResetLinkController::class, 'store'])
->middleware(['guest'])
->name('password.email');

Route::get('/reset-password/{token}', [NewPasswordController::class, 'create'])
->middleware(['guest'])
->name('password.reset');

Route::post('/reset-password', [NewPasswordController::class, 'store'])
->middleware(['guest'])
->name('password.update');
}

// Registration...
if (Features::enabled(Features::registration())) {
Route::get('/register', [RegisteredUserController::class, 'create'])
->middleware(['guest'])
->name('register');
if (! $disableViews) {
Route::get('/register', [RegisteredUserController::class, 'create'])
->middleware(['guest'])
->name('register');
}

Route::post('/register', [RegisteredUserController::class, 'store'])
->middleware(['guest']);
}

// Email Verification...
if (Features::enabled(Features::emailVerification())) {
Route::get('/email/verify', [EmailVerificationPromptController::class, '__invoke'])
->middleware(['auth'])
->name('verification.notice');
if (! $disableViews) {
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'])
Expand All @@ -94,22 +104,26 @@
}

// Password Confirmation...
Route::get('/user/confirm-password', [ConfirmablePasswordController::class, 'show'])
->middleware(['auth'])
->name('password.confirm');
if (! $disableViews) {
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']);

Route::get('/user/confirmed-password-status', [ConfirmedPasswordStatusController::class, 'show'])
->middleware(['auth'])
->name('password.confirmation');

// Two Factor Authentication...
if (Features::enabled(Features::twoFactorAuthentication())) {
Route::get('/two-factor-challenge', [TwoFactorAuthenticatedSessionController::class, 'create'])
->middleware(['guest'])
->name('two-factor.login');
if (! $disableViews) {
Route::get('/two-factor-challenge', [TwoFactorAuthenticatedSessionController::class, 'create'])
->middleware(['guest'])
->name('two-factor.login');
}

Route::post('/two-factor-challenge', [TwoFactorAuthenticatedSessionController::class, 'store'])
->middleware(['guest']);
Expand All @@ -124,11 +138,13 @@
Route::delete('/user/two-factor-authentication', [TwoFactorAuthenticationController::class, 'destroy'])
->middleware($twoFactorMiddleware);

Route::get('/user/two-factor-qr-code', [TwoFactorQrCodeController::class, 'show'])
->middleware($twoFactorMiddleware);
if (! $disableViews) {
Route::get('/user/two-factor-qr-code', [TwoFactorQrCodeController::class, 'show'])
->middleware($twoFactorMiddleware);

Route::get('/user/two-factor-recovery-codes', [RecoveryCodeController::class, 'index'])
->middleware($twoFactorMiddleware);
Route::get('/user/two-factor-recovery-codes', [RecoveryCodeController::class, 'index'])
->middleware($twoFactorMiddleware);
}

Route::post('/user/two-factor-recovery-codes', [RecoveryCodeController::class, 'store'])
->middleware($twoFactorMiddleware);
Expand Down
13 changes: 13 additions & 0 deletions stubs/fortify.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,19 @@

'email' => 'email',

/*
|--------------------------------------------------------------------------
| Disable Views
|--------------------------------------------------------------------------
|
| Here you may specify if the routes returning views should be disabled.
| You might want to activate this configuration if you are using your
| own front-end and you want to keep your application routes clean.
|
*/

'disable_views' => false,

/*
|--------------------------------------------------------------------------
| Home Path
Expand Down

0 comments on commit 31874d0

Please sign in to comment.