Opened 15 years ago

Closed 14 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 by libwilliam, 15 years ago

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 by Thejaswi Puthraya, 15 years ago

Component: UncategorizedAuthentication

comment:3 by Russell Keith-Magee, 15 years ago

milestone: 1.2
Triage Stage: UnreviewedAccepted

comment:4 by Bruno Renié, 15 years ago

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 by James Bennett, 15 years ago

milestone: 1.2

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

comment:6 by Julien Phalip, 14 years ago

Severity: Normal
Type: Bug

comment:7 by Jannis Leidel, 14 years ago

Easy pickings: unset
Resolution: fixed
Status: newclosed
UI/UX: unset

I believe this has been fixed a while ago.

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