## How to reproduce

1. Log out
2. Open a specific PH link (e.g. https://<PH instance>/person/338)
3. Login

## Expected behavior

I expect it to take me to the page I was intending to go to when I was logged out and not "Insights" page.

## Actual behavior

It takes me to the https://<PH instance>/insights...

## Environment

- PostHog cloud or self-managed? self-hosted
- PostHog version/commit: 1.17.0
posthog/urls.py
user,
)
from posthog.demo import demo
from posthog.email import is_email_available
from posthog.models.organization import Organization
from .models import OrganizationInvite, Team, User
from .utils import render_template
from .views import health, preflight_check, stats, system_status
def home(request, **kwargs):
    if request.path.endswith(".map") or request.path.endswith(".map.js"):
        return redirect("/static%s" % request.path)
    return render_template("index.html", request)
def login_view(request):
    if request.user.is_authenticated:
        return redirect("/")
    if not User.objects.exists():
        return redirect("/preflight")
    if request.method == "POST":
        email = request.POST["email"]
        password = request.POST["password"]
        user = cast(Optional[User], authenticate(request, email=email, password=password))
        if user is not None:
            login(request, user, backend="django.contrib.auth.backends.ModelBackend")
            if user.distinct_id:
                posthoganalytics.capture(user.distinct_id, "user logged in")
            return redirect("/")
        else:
            return render_template("login.html", request=request, context={"email": email, "error": True})
    return render_template("login.html", request)
class TeamInviteSurrogate: