Opened 6 years ago

Closed 4 years ago

#11954 closed Bug (fixed)

?next linking to a login_required view doesn't work

Reported by: libwilliam Owned by: nobody
Component: contrib.auth Version: 1.1
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

On my site I link to a view that is login_required and the url has a next param in it.

mysite.com/some_view/?next=/some_other_view/

When it arrives at the login page it looks like this.

mysite.com/accounts/login/?next=some_view/?next=/some_other_view/

It cannot handle that url so it redirects to /accounts/profile/

Change History (7)

comment:1 Changed 6 years ago by libwilliam

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

I also have another related problem.

I have a url mysite.com/+item that goes to a login_required view. When it arrives at the /accounts/login/ url it looks like this. mysite.com/accounts/login/?next=/%2Bitem/... It then doesn't redirect to the correct spot. I am guessing because of the %2B Is there a way around this?

comment:2 Changed 6 years ago by thejaswi_puthraya

  • Component changed from Uncategorized to Authentication

comment:3 Changed 5 years ago by russellm

  • milestone set to 1.2
  • Triage Stage changed from Unreviewed to Accepted

comment:4 Changed 5 years ago by brutasse

This looks invalid to me, the login template needs to look like this:

<form method="post" action="{% url login %}">
  {{ form.as_p }}
  {% if next %} {# this is REDIRECT_FIELD_NAME #}
  <input type="hidden" name="next" value="{{ next }}" />{% endif %}
  <input type="submit" value="Sign in" />
</form>

If the hidden input isn't added, there is no way the view can redirect to the right URL.

This is fully documented here (scroll down)

comment:5 Changed 5 years ago by ubernostrum

  • milestone 1.2 deleted

1.2 is feature-frozen, moving this feature request off the milestone.

comment:6 Changed 4 years ago by julien

  • Severity set to Normal
  • Type set to Bug

comment:7 Changed 4 years ago by jezdez

  • Easy pickings unset
  • Resolution set to fixed
  • Status changed from new to closed
  • UI/UX unset

I believe this has been fixed a while ago.

Note: See TracTickets for help on using tickets.
Back to Top