Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#28550 closed Bug (fixed)

auth's login/logout() views drop options passed as args rather the kwargs

Reported by: Clayton Daley Owned by: Zach Liu
Component: contrib.auth Version: 1.11
Severity: Release blocker Keywords:
Cc: Zach Liu Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description (last modified by Tim Graham)

I'm using django-userena which passes a custom template name into

from django.contrib.auth.views import logout as Signout
....
return Signout(request, next_page, template_name, *args, **kwargs)

By the time this call is converted to a view, the template_name reverts to the default (registration/logged_out.html). If I convert the arg to a kwarg (in userena), the call works correctly so the issue seems to be the way the view is constructed (in contrib.auth.views.logout():

return LogoutView.as_view(**kwargs)(request, *args, **kwargs)`

Since template_name is passed as an arg, it isn't included in the call to as_view() that actually sets attributes (including template_name. Before making this call, I suspect the logout() function should convert template_name (and possibly other args) into kwargs.

Change History (8)

comment:1 by Tim Graham, 7 years ago

Severity: NormalRelease blocker
Summary: LogoutView loses template_nameauth's login/logout() views drop options passed as args rather the kwargs
Triage Stage: UnreviewedAccepted
Type: UncategorizedBug

comment:2 by Tim Graham, 7 years ago

Description: modified (diff)

comment:3 by Zach Liu, 7 years ago

Cc: Zach Liu added
Owner: changed from nobody to Zach Liu
Status: newassigned

comment:4 by Zach Liu, 7 years ago

I understand that template_name (along with authentication_form, redirect_field_name, redirect_authenticated_user, extra_context) need to be included in **kwargs that is passed to as_view(), not sure about others in *arg.

It seems that as_view(**kwargs) will raise Error if a key in kwargs is not in class attributes of the view class. So I guess I need only find those arguments and add them to kwargs in LogoutView.as_view()?

Also if it happens to logout(), it should happen to login() too, right?

Last edited 7 years ago by Zach Liu (previous) (diff)

comment:5 by Tim Graham, 7 years ago

Some names may need to be transformed. For example, authentication_form becomes form_class. It looks like the other login() args have matching attributes in LoginView.

comment:6 by Tim Graham, 7 years ago

Has patch: set

comment:7 by Tim Graham <timograham@…>, 7 years ago

Resolution: fixed
Status: assignedclosed

In f8e0557:

[1.11.x] Fixed #28550 -- Restored contrib.auth's login() and logout() views' respect of positional arguments.

Regression in 78963495d0caadb77eb97ccf319ef0ba3b204fb5.

comment:8 by Tim Graham <timograham@…>, 7 years ago

In 2dacc2c:

Fixed #28550 -- Restored contrib.auth's login() and logout() views' respect of positional arguments.

Regression in 78963495d0caadb77eb97ccf319ef0ba3b204fb5.

Forwardport of f8e0557b01ebbb11478cfb012c4cafc67f1213c1 from stable/1.11.x

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