302 response status code is not an error. Everything is OK. That means that route to which successful login should be redirected has been found.
May 21, 2020
4
Level 4
authentication question - 302 code
Hi,
I am having issues with my authentication system. I am using laravel 7 and Laravel/UI
I had the following routes:
Route::prefix('/admin/')->name('admin.')->namespace('Admin\Auth')->group(function(){
Route::get('login', 'LoginController@showLoginForm')->name('login');
Route::post('login', 'LoginController@login')
Route::post('logout', 'LoginController@logout')->name('logout');
Route::get('password/reset', 'ForgotPasswordController@showLinkRequestForm')->name('password.request');
Route::post('password/email', 'ForgotPasswordController@sendResetLinkEmail')->name('password.email');
Route::get('password/reset/{token}', 'ResetPasswordController@showResetForm')->name('password.reset');
Route::post('password/reset', 'ResetPasswordController@reset')->name('password.update');
Route::get('password/confirm', 'ConfirmPasswordController@showConfirmForm')->name('password.confirm');
Route::post('password/confirm', 'ConfirmPasswordController@confirm');
Route::get('email/verify', 'VerificationController@show')->name('verification.notice');
Route::get('email/verify/{id}/{hash}', 'VerificationController@verify')->name('verification.verify');
Route::post('email/resend', 'VerificationController@resend')->name('verification.resend');
});
I have a dashboard module with
Route::group(['middleware' => ['web', 'auth:admin'], 'as' => 'admin.', 'prefix' => '/admin', 'namespace' => 'RF\RFCmsDashboard\Http\Controllers'], function()
{
App::setLocale(Session::get('lang'));
Route::redirect('/', '/admin/dashboard');
Route::get('dashboard','RFCmsDashboardController@index')->name('dashboard');
});
I can not figure what is gong on. When I submit the login form. I get redirected to my dashboard upon authentication but I can see in my browser inspector a 302 error related to the login page with POST. The type of the request is type/html. It is followed by the dashboard page with a code 200.
Request URL: http://127.0.0.1:8000/admin/login
Request Method: POST
Status Code: 302 Found
Remote Address: 127.0.0.1:8000
I can display the name of user which indicates the user must have logged in successfuly. I use this code to display the user name
{{ Auth::guard('admin')->user()->first_name }}
Level 61
1 like
Please or to participate in this conversation.