Skip to content

Commit

Permalink
Fix #3228 - UrlEncode full path for next if not on logon page
Browse files Browse the repository at this point in the history
Include the full path for the ?next= variable in login links if we are not on the logon page.
Additionally include next for post requests that have the next variable set (will only come from the login page itself generally)
  • Loading branch information
DanSheps committed May 30, 2019
1 parent 1958c0b commit 814c50f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion netbox/templates/inc/nav_menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,12 @@
</ul>
</li>
{% else %}
<li><a href="{% url 'login' %}?next={{ request.path }}"><i class="fa fa-sign-in"></i> Log in</a></li>
{% url 'login' as login_url %}
{% if request.path == login_url %}
<li><a href="{{ request.get_full_path }}"><i class="fa fa-sign-in"></i> Log in</a></li>
{% else %}
<li><a href="{{ login_url }}?next={{ request.get_full_path | urlencode }}"><i class="fa fa-sign-in"></i> Log in</a></li>
{% endif %}
{% endif %}
</ul>
<form action="{% url 'search' %}" method="get" class="navbar-form navbar-right" id="navbar_search" role="search">
Expand Down
1 change: 1 addition & 0 deletions netbox/templates/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<div class="panel-body">
{% csrf_token %}
{% if 'next' in request.GET %}<input type="hidden" name="next" value="{{ request.GET.next }}" />{% endif %}
{% if 'next' in request.POST %}<input type="hidden" name="next" value="{{ request.POST.next }}" />{% endif %}
{% render_form form %}
</div>
<div class="panel-footer text-right">
Expand Down

0 comments on commit 814c50f

Please sign in to comment.