I am working on a requirement where I send emails after record update/insert in which I send page URL as "click here" text, when user clicks on that link he will be redirected to that page regardless of user logs in or not.
Now if the user already logged-in then that page normally opens but if user is not logged-in then I need to redirect back to previous page after login.
My Problem here is I am unable to redirect back to the previous page which user tried to access before login through 'click here' link from email
I have searched for the solutions I found few but they were not working. One of the solution I tried is Scott's answer but din't work why because our application authentication is totally customized. Our RedirectIfAuthenticated file code is below
NOTE: Our application has been built on Laravel
RedirectIfAuthenticated.php
class RedirectIfAuthenticated
{
public function handle($request, Closure $next, $guard = null)
{
$path = $request->path();
if (Auth::guard($guard)->check()) {
if($path == 'app1')
{
return redirect('/app1/dashboard');
}
elseif($path == 'app2')
{
return redirect('/app2/dashboard');
}
}
return $next($request);
}
}
Any help would be appreciated. Thanks