'Override default Auth routes in Laravel 7
I need to custom routes of Auth::routes();
, I can not find them, try search in Router.php
Vendor\laravel\framework\src\Illuminate\Routing\Router.php
But I didn't find them!
Solution 1:[1]
In Laravel(5.+, 6,7,8) ui Auth::routes();
uses a function auth()
defined in vendor/laravel/ui/src/AuthRouteMethods.php
You can copy the content of this function and paste it directly in your web.php
route file file and update as you want like below or something else.
// Login Routes...
Route::get('admin-login', 'Admin\LoginController@showLoginForm')->name('admin.login');
Route::post('admin-login', 'Admin\LoginController@login');
// Logout Routes...
Route::post('admin-logout', 'Admin\LoginController@logout')->name('admin.logout');
// Registration Routes...
Route::get('admin-register', 'Admin\RegisterController@showRegistrationForm')->name('admin.register');
Route::post('admin-register', 'Admin\RegisterController@register');
// Password Reset Routes...
Route::get('admin-password/reset', 'Admin\ForgotPasswordController@showLinkRequestForm')->name('admin.password.request');
Route::post('admin-password/email', 'Admin\ForgotPasswordController@sendResetLinkEmail')->name('admin.password.email');
Route::get('admin-password/reset/{token}', 'Admin\ResetPasswordController@showResetForm')->name('admin.password.reset');
Route::post('admin-password/reset', 'Admin\ResetPasswordController@reset')->name('admin.password.update');
// Password Confirmation Routes...
Route::get('admin-password/confirm', 'Admin\ConfirmPasswordController@showConfirmForm')->name('admin.password.confirm');
Route::post('admin-password/confirm', 'Admin\ConfirmPasswordController@confirm');
// Email Verification Routes...
Route::get('admin-email/verify', 'Admin\VerificationController@show')->name('admin.verification.notice');
Route::get('admin-email/verify/{id}/{hash}', 'Admin\VerificationController@verify')->name('admin.verification.verify');
Route::post('admin-email/resend', 'Auth\VerificationController@resend')->name('admin.verification.resend');
Solution 2:[2]
Don't need to override Auth::routes()
. Remove it from your route file and put your own custom route there. Auth facade have routes() method and it call auth() method from Router class to register Auth routes.
Solution 3:[3]
The Auth::routes()
function takes an optional parameter $options
. You can manually disable certain routes like this:
Auth::routes(['register' => false]);
Solution 4:[4]
php artisan route:list
Please try with this artisan command.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | Hashemi Rafsan |
Solution 3 | gX. |
Solution 4 | lovecoding |