I have an issue with laravel route. I want that auth register route can be access by only admin or logged users. To achieve this i have removed Route::auth();
from routes.php and create my own route entry in auth middleware.
Effort
Route::group(['middleware' => 'web'], function () {
// Authentication Routes...
$this->get('login', 'Auth\AuthController@showLoginForm');
$this->post('login', 'Auth\AuthController@login');
$this->get('logout', 'Auth\AuthController@logout');
// 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');
Route::get('/home', 'HomeController@index');
Route::post('/ajax/getStates', 'ConfigurationController@getStates');
Route::post('/ajax/getCities', 'ConfigurationController@getCities');
});
Route::group(['middleware' => ['web','auth']], function () {
// Registration Routes...
$this->get('register', 'Auth\AuthController@showRegistrationForm');
$this->post('register', 'Auth\AuthController@register');
});
Above code working fine. when i tried to access register url it simply redirect me to the login page. Now actual problem start after login.
After login, i tried to access register page, but it does not show up, instead it redirect me to the home like http://localhost/
.
Please suggest me the solution.
register route
within yourauth
middleware instead you need to get it within yourweb
middleware only so you can access it without logging – Narendrasingh SisodiaAuthController
– Narendrasingh Sisodia