I have the following in my RedirectifAuthenticated middleware:
public function handle($request, Closure $next, $guard = null) { if (Auth::guard($guard)->check()) { return redirect('dashboard'); } return $next($request); } But when a user logs in, this is redirecting to /home which I renamed to /dashboard.
I have changed the routes, views etc from home to dashboard.
I have run a search throughout the whole projects and I cannot find a route to /home or a mention of home that is not the title or in unrelated filed such as the yarn.lock file.
I have found many articles on this issue but I do not have an Authenticate.php not do I have the old Auth middleware.
EDIT: Below are my Login Controller and routes:
LoginController:
<?php namespace App\Http\Controllers\Auth; use App\Http\Controllers\Controller; use Illuminate\Foundation\Auth\AuthenticatesUsers; use Illuminate\Http\Request; class LoginController extends Controller { /* |-------------------------------------------------------------------------- | Login Controller |-------------------------------------------------------------------------- | | This controller handles authenticating users for the application and | redirecting them to your home screen. The controller uses a trait | to conveniently provide its functionality to your applications. | */ use AuthenticatesUsers; /** * Where to redirect users after login. * * @var string */ //protected $redirectTo = '/dashboard'; public function authenticated(Request $request) { // Logic that determines where to send the user if($request->user()->hasRole('Stallhollder')){ return redirect('/dashboard'); } if($request->user()->hasRole('Manager')){ return redirect('/dashboard2'); } } /** * Create a new controller instance. * * @return void */ public function __construct() { $this->middleware('guest')->except('logout'); } } Routes:
<?php /* |-------------------------------------------------------------------------- | Web Routes |-------------------------------------------------------------------------- | | Here is where you can register web routes for your application. These | routes are loaded by the RouteServiceProvider within a group which | contains the "web" middleware group. Now create something great! | */ Route::get('/', function () { return view('welcome'); }); Auth::routes(); Route::get('/dashboard', 'DashboardController@index'); Route::resource('/bookings', 'BookingsController'); Route::get('/dashboard2', function () { return view('dashboard2'); });
LoginController? And maybeRedirectIfAuthenticatedmiddleware as wellRoutes Code... AndViewFileRoute::get('/dashboard', 'DashboardController@index');its go toindexpage andindexpage redirect to home page.