RFFRED
5 months ago
1027
3
Laravel

authentication question - 302 code

Posted 5 months ago by RFFRED

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', '[email protected]')->name('login');
    Route::post('login', '[email protected]')
    Route::post('logout', '[email protected]')->name('logout');

    Route::get('password/reset', '[email protected]')->name('password.request');
    Route::post('password/email', '[email protected]')->name('password.email');
    Route::get('password/reset/{token}', '[email protected]')->name('password.reset');
    Route::post('password/reset', '[email protected]')->name('password.update');

    Route::get('password/confirm', '[email protected]')->name('password.confirm');
    Route::post('password/confirm', '[email protected]');

    Route::get('email/verify', '[email protected]')->name('verification.notice');
    Route::get('email/verify/{id}/{hash}', '[email protected]')->name('verification.verify');
    Route::post('email/resend', '[email protected]')->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','[email protected]')->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 }}

Please sign in or create an account to participate in this conversation.