lundi 9 mars 2020

ERR_TOO_MANY_REDIRECTS in laravel login

i have made to users one of the have roles "admin" and the second have "codingTeam" and in loginControler i override redirectTo that send admin to home lade and the codingTeam to codingTeam blade and this is my method

    protected function redirectTo()
    {
        $role = Auth::user()->roles;

        switch($role){
            case 'codingTeam' : 
                return 'codingTeam';
            break;

            case 'admin' : 
                return 'home';
            break;
            default:
                return 'home';
            break;
        }
    }

and this is my web.php file

<?php

Route::get('/', function () {
    return view('login');
});

Route::group(['middleware' => ['auth']], function(){

Route::get('codingTeam','CodingTeamController@index')->name('codingTeam');

Route::get('/home', 'HomeController@index')->name('home');

Auth::routes();

Route::post('insert','Friends@insert');

Route::get('/logout', '\App\Http\Controllers\Auth\LoginController@logout');

Route::get('codingTeam','CodingTeamController@index')->name('codingTeam');

});


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire