Clean up routes and middleware checking

This commit is contained in:
Dane Everitt 2016-01-04 16:09:39 -05:00
parent 99a67127c9
commit 4ae8a45ed3
16 changed files with 321 additions and 101 deletions

View file

@ -9,23 +9,63 @@ use Pterodactyl\Models\User as User;
class AuthRoutes {
public function map(Router $router) {
$router->group(['prefix' => 'auth'], function () use ($router) {
$router->group([
'prefix' => 'auth',
'middleware' => [
'guest'
]
], function () use ($router) {
$router->get('login', [ 'as' => 'auth.login', 'uses' => 'Auth\AuthController@getLogin' ]);
$router->post('login', [ 'uses' => 'Auth\AuthController@postLogin' ]);
$router->post('login/totp', [ 'uses' => 'Auth\AuthController@checkTotp' ]);
// Display Login Page
$router->get('login', [
'as' => 'auth.login',
'uses' => 'Auth\AuthController@getLogin'
]);
// Handle Login
$router->post('login', [
'uses' => 'Auth\AuthController@postLogin'
]);
$router->get('password', [ 'as' => 'auth.password', 'uses' => 'Auth\PasswordController@getEmail' ]);
$router->post('password', [ 'as' => 'auth.password.submit', 'uses' => 'Auth\PasswordController@postEmail' ], function () {
// Determine if we need to ask for a TOTP Token
$router->post('login/totp', [
'uses' => 'Auth\AuthController@checkTotp'
]);
// Show Password Reset Form
$router->get('password', [
'as' => 'auth.password',
'uses' => 'Auth\PasswordController@getEmail'
]);
// Handle Password Reset
$router->post('password', [
'as' => 'auth.password.submit',
'uses' => 'Auth\PasswordController@postEmail'
], function () {
return redirect('auth/password')->with('sent', true);
});
$router->post('password/verify', [ 'uses' => 'Auth\PasswordController@postReset' ]);
$router->get('password/verify/{token}', [ 'as' => 'auth.verify', 'uses' => 'Auth\PasswordController@getReset' ]);
$router->get('logout', [ 'as' => 'auth.logout', 'uses' => 'Auth\AuthController@getLogout' ]);
// Show Verification Checkpoint
$router->get('password/verify/{token}', [
'as' => 'auth.verify',
'uses' => 'Auth\PasswordController@getReset'
]);
// Handle Verification
$router->post('password/verify', [
'uses' => 'Auth\PasswordController@postReset'
]);
});
// Not included above because we don't want the guest middleware
$router->get('logout', [
'as' => 'auth.logout',
'middleware' => 'auth',
'uses' => 'Auth\AuthController@getLogout'
]);
}
}