How to change the default Laravel authentication routes such as Login and register to your own custom-defined routes.
/login to /signin.
I am using Laravel UI which comes with embedded authentication routes. These are called with Auth::routes(); in the routes/web.php file.
The best way to create your own custom route for login is to disable the default Laravel UI route
Auth::routes(['login' => false]);
Then define your own
Route::get('signin', 'App\Http\Controllers\Auth\LoginController@showLoginForm');
Route::post('signin', 'App\Http\Controllers\Auth\LoginController@login')->name('login'); Use the source as a template for controller and functions, by keeping the route named as login it will automatically be this custom route whenever a redirect to “login” occurs.
Now to change /register to /create
Auth::routes(['login' => false, 'register' => false]);
Route::get('create', 'App\Http\Controllers\Auth\RegisterController@showRegistrationForm');
Route::post('create', 'App\Http\Controllers\Auth\RegisterController@register')->name('register'); Make sure to run php artisan route:cache after editing routes.
A drained and empty Kennington reservoir images from a drone in early July 2024. The…
Merrimu Reservoir from drone. Click images to view larger.
Some early September spring shots from a bushwalk, It is still too early for wildflowers.
I recently needed to clone over a smaller NVMe to a 2TB SK Hynix Platinum…
If you ever needed a simple solution in Laravel to delete an entire directory and…
How to enforce only one user to register or be registered in a Laravel web…