Switch to more recent Laravel route definition methods

This commit is contained in:
DaneEveritt 2022-05-14 15:51:05 -04:00
parent 62b178ed02
commit 65f27d41a2
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
9 changed files with 278 additions and 308 deletions

View file

@ -1,5 +1,7 @@
<?php
use Pterodactyl\Http\Controllers\Auth;
/*
|--------------------------------------------------------------------------
| Authentication Routes
@ -8,44 +10,40 @@
| Endpoint: /auth
|
*/
Route::group(['middleware' => 'guest'], function () {
// These routes are defined so that we can continue to reference them programatically.
// They all route to the same controller function which passes off to Vuejs.
Route::get('/login', 'LoginController@index')->name('auth.login');
Route::get('/password', 'LoginController@index')->name('auth.forgot-password');
Route::get('/password/reset/{token}', 'LoginController@index')->name('auth.reset');
// Apply a throttle to authentication action endpoints, in addition to the
// recaptcha endpoints to slow down manual attack spammers even more. 🤷‍
//
// @see \Pterodactyl\Providers\RouteServiceProvider
Route::middleware(['throttle:authentication'])->group(function () {
// Login endpoints.
Route::post('/login', 'LoginController@login')->middleware('recaptcha');
Route::post('/login/checkpoint', 'LoginCheckpointController')->name('auth.login-checkpoint');
// These routes are defined so that we can continue to reference them programatically.
// They all route to the same controller function which passes off to React.
Route::get('/login', [Auth\LoginController::class, 'index'])->name('auth.login');
Route::get('/password', [Auth\LoginController::class, 'index'])->name('auth.forgot-password');
Route::get('/password/reset/{token}', [Auth\LoginController::class, 'index'])->name('auth.reset');
// Forgot password route. A post to this endpoint will trigger an
// email to be sent containing a reset token.
Route::post('/password', 'ForgotPasswordController@sendResetLinkEmail')
->name('auth.post.forgot-password')
->middleware('recaptcha');
});
// Apply a throttle to authentication action endpoints, in addition to the
// recaptcha endpoints to slow down manual attack spammers even more. 🤷‍
//
// @see \Pterodactyl\Providers\RouteServiceProvider
Route::middleware(['throttle:authentication'])->group(function () {
// Login endpoints.
Route::post('/login', [Auth\LoginController::class, 'login'])->middleware('recaptcha');
Route::post('/login/checkpoint', Auth\LoginCheckpointController::class)->name('auth.login-checkpoint');
// Password reset routes. This endpoint is hit after going through
// the forgot password routes to acquire a token (or after an account
// is created).
Route::post('/password/reset', 'ResetPasswordController')->name('auth.reset-password');
// Catch any other combinations of routes and pass them off to the Vuejs component.
Route::fallback('LoginController@index');
// Forgot password route. A post to this endpoint will trigger an
// email to be sent containing a reset token.
Route::post('/password', [Auth\ForgotPasswordController::class, 'sendResetLinkEmail'])
->name('auth.post.forgot-password')
->middleware('recaptcha');
});
/*
|--------------------------------------------------------------------------
| Routes Accessible only when logged in
|--------------------------------------------------------------------------
|
| Endpoint: /auth
|
*/
Route::post('/logout', 'LoginController@logout')->name('auth.logout')->middleware('auth', 'csrf');
// Password reset routes. This endpoint is hit after going through
// the forgot password routes to acquire a token (or after an account
// is created).
Route::post('/password/reset', Auth\ResetPasswordController::class)->name('auth.reset-password');
// Remove the guest middleware and apply the authenticated middleware to this endpoint
// so it cannot be used unless you're already logged in.
Route::post('/logout', [Auth\LoginController::class, 'logout'])
->withoutMiddleware('guest')
->middleware('auth')
->name('auth.logout');
// Catch any other combinations of routes and pass them off to the Vuejs component.
Route::fallback([Auth\LoginController::class, 'index']);