I have two login forms with two different tables. One has a default /login route, and the other has a /myportal route. I have an additional login
protected $redirectTo = '/student-home'; public function showLoginForm() { return view('my_portal'); } public function logout(Request $request) { $this->guard()->logout(); $request->session()->flush(); $request->session()->regenerate(); return redirect('/my_portal'); } protected function guard() { return Auth::guard('web_student'); } public function username () { return 'username'; }
This login is working fine. But I have a problem with RedirectIfAuthenticated
public function handle($request, Closure $next, $guard = null) { if (Auth::guard($guard)->check()) { return redirect('/home'); } else if(Auth::guard('web_student')->check()) { return redirect('student-home'); } return $next($request); }
Now, if the user is already registered, he will be redirected to /student-home only if the route is /login and not /my-portal . ie only if I click on the regular form, and not this additional form that I created. How can I redirect to student-home if the user clicked on /my-portal ?
source share