One possible solution is to add a query parameter to the login URL indicating which tab the user is coming from. Then, in the LoginController, you can use this parameter to determine the correct redirect URL.
For example, in the home and alerts pages, you can add the query parameter like this:
<a href="{{ route('login') }}?tab=home">Login from Home</a>
<a href="{{ route('login') }}?tab=alerts">Login from Alerts</a>
Then, in the LoginController, you can modify the check_login method to use the tab parameter:
public function check_login(Request $request)
{
// authenticate user via LDAP
// ...
// determine redirect URL based on tab parameter
$tab = $request->input('tab');
if ($tab === 'alerts') {
$redirectUrl = '/alerts';
} else {
$redirectUrl = '/home';
}
return redirect($redirectUrl);
}
This way, the user will be redirected to the correct tab after logging in.