RSAdmin
RSAdmin

Reputation: 589

Laravel 5.2: where are auth routes declared?

I need to rearrange the urls used by the auth system. Laravel 5.2. I used artisan make:auth and now I can't locate where the router is told what to do with /login and /logout. IMHO, it seems to me a step backwards in the 'ease of use' Laravel strives for that so many commonly overridden features should hav ebecome so obscured in recent revisions.

I'm dividing up the app into admin and public areas and there are to be separate login mechanisms for each: /admin/login is to be handled by the core Laravel system, and /login will be for frontside admin users, auth handled by a different set of classes.

Can someone clue me in please?

Upvotes: 4

Views: 3455

Answers (3)

Can Celik
Can Celik

Reputation: 2087

You just need to change two parameters for the paths.

protected $redirectPath = '/dashboard';

When a user is successfully authenticated, they will be redirected to the this path.

Second one is the login path. You can customize the failed post-authentication redirect location by defining a loginPath property on the AuthController:

protected $loginPath = '/login';

Upvotes: 0

Maytham Fahmi
Maytham Fahmi

Reputation: 33377

What you need is to build 2 systems one for public and one for admin.

Jeffrey Way (Laracast) has made a video explaining every thing you need to build a complete customized login system that is equal to what you get of artisan make:auth.

The video link is https://laracasts.com/lessons/email-verification-in-laravel. The video is not free, but Jeffrey has the code available on this git (https://github.com/laracasts/Email-Verification-In-Laravel).

I have used it to build two separate system using the same database.

Note: the link is called email verification in Laravel, but it covers every thing for authentication.

Upvotes: 2

Jeff
Jeff

Reputation: 25211

php artisan make:auth adds the following line to your routes file:

Route::group(['middleware' => 'web'], function () {
    Route::auth();
}

Route::auth() is a shortcut to defining the following routes:

// Authentication Routes...
$this->get('login', 'Auth\AuthController@showLoginForm');
$this->post('login', 'Auth\AuthController@login');
$this->get('logout', 'Auth\AuthController@logout');

// Registration Routes...
$this->get('register', 'Auth\AuthController@showRegistrationForm');
$this->post('register', 'Auth\AuthController@register');

// Password Reset Routes...
$this->get('password/reset/{token?}', 'Auth\PasswordController@showResetForm');
$this->post('password/email', 'Auth\PasswordController@sendResetLinkEmail');
$this->post('password/reset', 'Auth\PasswordController@reset');

So assuming you ran auth:make and haven't touched anything, those will be the routes you can use.

Source: https://mattstauffer.co/blog/the-auth-scaffold-in-laravel-5-2#routeauth

Upvotes: 6

Related Questions