Files

58 lines
2.4 KiB
PHP
Raw Permalink Normal View History

2016-01-20 22:39:02 -05:00
<?php
2026-10-05 18:10:18 -04:00
declare(strict_types=1);
2022-12-01 11:49:54 -07:00
use Illuminate\Support\Facades\Route;
2026-10-05 18:10:18 -04:00
use Pterodactyl\Http\Controllers\Auth\ForgotPasswordController;
use Pterodactyl\Http\Controllers\Auth\LoginCheckpointController;
use Pterodactyl\Http\Controllers\Auth\LoginController;
use Pterodactyl\Http\Controllers\Auth\ResetPasswordController;
/*
|--------------------------------------------------------------------------
| Authentication Routes
|--------------------------------------------------------------------------
|
| Endpoint: /auth
|
*/
2022-12-01 11:49:54 -07:00
// These routes are defined so that we can continue to reference them programmatically.
// They all route to the same controller function which passes off to React.
2026-10-05 18:10:18 -04:00
Route::get('/login', [LoginController::class, 'index'])->name('auth.login');
Route::get('/password', [LoginController::class, 'index'])->name('auth.forgot-password');
Route::get('/password/reset/{token}', [LoginController::class, '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. 🤷‍
//
2026-10-05 18:10:18 -04:00
// @see bootstrap/app.php (withRouting)
Route::middleware(['throttle:authentication'])->group(function (): void {
// Login endpoints.
2026-10-05 18:10:18 -04:00
Route::post('/login', [LoginController::class, 'login'])->middleware('recaptcha');
Route::post('/login/checkpoint', LoginCheckpointController::class)->name('auth.login-checkpoint');
// Forgot password route. A post to this endpoint will trigger an
// email to be sent containing a reset token.
2026-10-05 18:10:18 -04:00
Route::post('/password', [ForgotPasswordController::class, 'sendResetLinkEmail'])
->name('auth.post.forgot-password')
->middleware('recaptcha');
2026-10-06 13:13:39 +01:00
// 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::class)
->name('auth.reset-password')
->middleware('recaptcha');
});
2022-12-01 11:49:54 -07:00
// Remove the guest middleware and apply the authenticated middleware to this endpoint,
// so it cannot be used unless you're already logged in.
2026-10-05 18:10:18 -04:00
Route::post('/logout', [LoginController::class, 'logout'])
->withoutMiddleware('guest')
->middleware('auth')
->name('auth.logout');
2022-12-01 11:49:54 -07:00
// Catch any other combinations of routes and pass them off to the React component.
2026-10-05 18:10:18 -04:00
Route::fallback([LoginController::class, 'index']);