In my Laravel app I have a private page which can be only accessed by Auth users. I am also using social logins, so when a user goes to private page without logging in, Laravel sends user to login page and after successful login, the user is sent back to original destination (private page). Only when a user logs in via Laravel inbuilt Auth system, but when a user logs in via the Social Login method, the user will be directed to the homepage.
This is my Social Login handler after login:
public function handleProviderCallback($provider)
{
$user = Socialite::driver($provider)->user();
$authUser = $this->findOrCreateUser($user, $provider);
Auth::login($authUser, true);
return redirect('/home');
}
How can I send the user to the original destination if it's present in session, otherwise send them back to home.