4

I'm trying to login an Admin and a User with the same form, but the config/auth I just only can to set a one default

This is my config/auth

'defaults' => [ 'guard' => 'web_users', 'passwords' => 'users', ], 'guards' => [ 'web_users' => [ 'driver' => 'session', 'provider' => 'users', ], 'web_admins' => [ 'driver' => 'session', 'provider' => 'admins', ], 'api' => [ 'driver' => 'token', 'provider' => 'users', ], ], 'providers' => [ 'users' => [ 'driver' => 'eloquent', 'model' => App\User::class, ], 'admins' => [ 'driver' => 'eloquent', 'model' => App\Admin::class, ], ], 

When I log in a User with the default "web_users" I can retrieve his data with the method Auth::user(), but if I log in a Admin with the default "web_admins" can't retrieve anything.

Routes:

Route::resource('log','LogController'); Route::get('logout','LogController@logout'); 

Log Controller

public function store(Request $request) { if(Auth::guard('web_users')->attempt(['email'=>$request['email'],'password'=>$request['password']])) { return Redirect::to('/'); } if(Auth::guard('web_admins')->attempt(['email'=>$request['email'],'password'=>$request['password']])) { return Redirect::to('/'); } } public function logout() { Auth::logout(); return Redirect::to('log'); } 

Note: sorry for my english, I don't speak it very well

1

1 Answer 1

0

try this for Routes file

Route::group(['middleware' => 'auth:web_users,web_admin'], function () { Route::resource('log','LogController'); Route::get('logout','LogController@logout'); }); 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.