I have 3 types of users as a customer, retailer and administrator. On the client side, they can access services without an initial login. But, nevertheless, there are several routes in which login is required as an example for a download page that requires a login. I have a char database field to find the type of user in a user table. After a successful login, I redirect back to the index page of different types of users. But suppose that a client who has not yet entered the access system to access services, and suddenly he clicks on a route that requires authorization, then he will be redirected to the login pager, where the user can enter the system. But after this login, they are also redirected back to the index page, not the page requesting login.How can I redirect it back to the requested page. The following are snippets of code. Thanks you
Web.php (only part shown here, other client routes not inside auth middleware)
Route::group(['middleware' => 'auth'], function () {
Route::get('/cart','searchController@viewCart' );
Route::get('/cart/changeStatus','searchController@changeCartStatus' );
});
authenticated login controller function
protected function authenticated($request, $user)
{
if($user->type === 'c') {
return redirect('/home');
}
else if($user->type === 'a') {
return redirect('/admin/home');
}
else if($user->type === 'r') {
return redirect('/retailer/home');
}
}
source
share