What's behind the routes?

If you use Laravel UI package, you likely want to know what routes are actually behind Auth::routes()?

You can check the file /vendor/laravel/ui/src/AuthRouteMethods.php.

1public function auth()
2{
3 return function ($options = []) {
4 // Authentication Routes...
5 $this->get('login', 'Auth\LoginController@showLoginForm')->name('login');
6 $this->post('login', 'Auth\LoginController@login');
7 $this->post('logout', 'Auth\LoginController@logout')->name('logout');
8 // Registration Routes...
9 if ($options['register'] ?? true) {
10 $this->get('register', 'Auth\RegisterController@showRegistrationForm')->name('register');
11 $this->post('register', 'Auth\RegisterController@register');
12 }
13 // Password Reset Routes...
14 if ($options['reset'] ?? true) {
15 $this->resetPassword();
16 }
17 // Password Confirmation Routes...
18 if ($options['confirm'] ?? class_exists($this->prependGroupNamespace('Auth\ConfirmPasswordController'))) {
19 $this->confirmPassword();
20 }
21 // Email Verification Routes...
22 if ($options['verify'] ?? false) {
23 $this->emailVerification();
24 }
25 };
26}

The default use of that function is simply this:

1Auth::routes(); // no parameters

But you can provide parameters to enable or disable certain routes:

1Auth::routes([
2 'login' => true,
3 'logout' => true,
4 'register' => true,
5 'reset' => true, // for resetting passwords
6 'confirm' => false, // for additional password confirmations
7 'verify' => false, // for email verification
8]);

Tip is based on suggestion by MimisK13

Like our articles?

Become a Premium Member for $129/year or $29/month
What else you will get:
  • 22 courses (477 lessons, total 38 h 20 min)
  • 2 long-form tutorials (one new every week)
  • access to project repositories
  • access to private Discord