omab / python-social-auth

Social auth made simple
http://psa.matiasaguirre.net
BSD 3-Clause "New" or "Revised" License
2.83k stars 1.09k forks source link

login redirect should work with a null request parameter #961

Closed fabiommendes closed 7 years ago

fabiommendes commented 8 years ago

I am using the Djinga templating engine (which processes both Django and Jinja templates) so I am not sure if this behavior is reproducible either in the vanilla Django template or even Jinja2. The social.apps.django_app.context_processors.login_redirect context processor fails when rendering using the django.template.loader.render_to_string() function.

The reason is very simple: Djinga passes request=None to all context processors when render_to_string is called and login_redirect fails with this kind of input. I am not sure if Djinga is abusing an undocumented Django behavior or login_redirect is the one to blame.

Anyway, the error can be fixed trivially by checking if request is None in the begining of the login redirect function.

omab commented 7 years ago

login_redirect can't ignore the request is a required parameter, if doesn't fit your current setup, that means that you need a custom function for that particular environment.