Juliver Galleto
Juliver Galleto

Reputation: 9037

change the authentication route Laravel 5

how can I change the authentication route like 'auth/login' to 'career/login' and 'auth/logout' to 'career/logout'? by default it is 'auth/login' and 'auth/logout'

Upvotes: 1

Views: 329

Answers (2)

Wader
Wader

Reputation: 9883

You simply just need to change your app/Http/routes.php and edit the routes for your AuthController.

Route::get('/career/login', 'Auth\AuthController@getLogin');
Route::get('/career/logout', 'Auth\AuthController@getLogout');

You can also define several properties on your AuthController.php to change things such as where the user is redirected after logging in, logging out, etc.

AuthController.php

// Where the user should be redirected after logging in.
protected $redirectPath = '/career';

// Where the user should be redirected after logging out.
protected $redirectAfterLogout = '/career/login';

Update:

If you're changing the login route I would also suggest you change the app\Http\Middleware\Authenticate.php middleware to redirect to your new login route when someone isn't authenticated on a protected page.

return redirect()->guest('career/login');

Upvotes: 4

JP_
JP_

Reputation: 1666

Check out routes.php in the app directory.

Here is an example of one of my development ones:

Route::get('/authtest', array('before' => 'auth.basic', function()
{
    return Response::json(array(
        'error'  => false,
        'result' => ''
    ), 200);
}));

// Route group for API versioning
Route::group(array('prefix' => 'api/v1', 'before' => 'auth.basic'), function()
{
    Route::controller('user', 'UserController');
    Route::resource('account', 'AccountController');
    Route::resource('order', 'OrderController');
    Route::resource('appointment', 'AppointmentController');
    Route::resource('invoice', 'InvoiceController');
    Route::resource('item', 'ItemController');
    Route::resource('itemcategory', 'ItemCategory');
});

Upvotes: 1

Related Questions