Opened 14 years ago

Closed 14 years ago

#15585 closed (wontfix)

Login view should call an empty hook in the authentication form

Reported by: freyley Owned by: nobody
Component: contrib.auth Version: 1.2
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

In django.contrib.auth.views.login, it'd be really nice if this:

# Okay, security checks complete. Log the user in.
auth_login(request, form.get_user())

if request.session.test_cookie_worked():

request.session.delete_test_cookie()


return HttpResponseRedirect(redirect_to)

were changed to this:

# Okay, security checks complete. Log the user in.
auth_login(request, form.get_user())

form.after_login_hook(request)


if request.session.test_cookie_worked():

request.session.delete_test_cookie()


return HttpResponseRedirect(redirect_to)

(and, django.contrib.auth.forms.AuthenticationForm, add

def after_login_hook(self, request):

pass

)

To allow for people who want to affect the session after login. The use case I just wanted it for is is adding a "remember me" checkbox. I can add it to the form easily enough, but since the form doesn't have access to the session, I also have to duplicate the view.

Change History (1)

comment:1 by Luke Plant, 14 years ago

Resolution: wontfix
Status: newclosed

I'm pretty sure that this can easily be achieved by use of the user_logged_in signal. Please re-open if there is a reason this will not work.

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