Re: Django custom authentication
I checked for the session cookie...
On Tuesday, 22 October 2013 20:44:16 UTC+5:30, Praveen Madhavan wrote:
-- It is getting created, could it be the django version ? I am using django 1.5 and I found few django openid apps not working on 1.5 .
On Tuesday, 22 October 2013 20:44:16 UTC+5:30, Praveen Madhavan wrote:
Tom
Thanks for the response, here is my view
def home(request):
if not request.user.is_authenticated():
# I have written my own custom authenticate method that returns an user object
user=authenticate(request=request)
if not user:
return HttpResponseRedirect("/accounts")
else:
login(request,user)
return HttpResponse("Logged in Successfully")
else:
return HttpResponse(request.user)
On Tuesday, 22 October 2013 18:30:13 UTC+5:30, Tom Evans wrote:On Tue, Oct 22, 2013 at 12:53 PM, Praveen Madhavan
<prave...@gmail.com> wrote:
> Hello All,
>
> I am trying custom authentication with django, I wrote a class and
> filled it with the methods authenticate and get_user, I also added this
> authentication to the AUTHENTICATION_BACKENDS in settings.py file.
>
> I have called my custom authenticate method and followed it up with
> login in my view.
Show us this view. You should not be calling a "custom authenticate
method", you should be using login() and authenticate() from
django.contrib.auth. If you are not, then this explains why on
subsequent views you are not logged in.
>
> Everything seems to work fine, is_authenticated returns true for the
> user after login, but the subsequent requests have request.user as
> anonymous, unable to figure out the reason, require your help
The other cause of login failing is if your browser does not send the
session cookie back to the server. This would happen if you have
configured django to send cookies with a different host than the pages
are served from. Use chrome inspector or firefox or any other tool you
fancy to determine if this is the case.
The easiest way to see is to look at the session cookie sent with the
pre-login page response, and the session cookie sent with the
post-login page response, do they have different ids?
Cheers
Tom
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b447397c-084f-4de1-b498-43b4557d41f6%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home