I need to check for existence of certain data before redirecting the user to login (if not authenticated). The reason is to prevent the user from having to complete unecessarily the login process if the data he's looking for doesn't exist.
Since I don't want auth middleware to kick in BEFORE my data verifications, right now, in my controller action, I do :
// some data checking before...
if ($dataExists) {
if (Auth::check()) {
return view('data', ['data' => $data]);
} else {
return redirect('login');
}
} else {
return view('notfound');
}
Everything is fine, except when the login completes, I'm unable to go back to the original URL the user was asking for...