Re: request.user returning AnonymousUser

2013-07-22 Thread l33t

Hello,

The problem is fixed. I was not using the get_user method in the custom 
authentication backend properly.

Best Regards,
Goose.


On Friday, July 19, 2013 1:04:22 PM UTC+2, l33t wrote:
>
>
> Hello,
>
> I have a custom authentication backend and a custom user model. The 
> authentication() method in the custom authentication backend returns the 
> custom user after successful authentication. Once authenticated, I use 
> login from django.contrib.auth to set the sessionid for the custom user.
> Now, I create a method as shown below:
> *
> def myview(request):
> if not request.user.is_authenticated():
> return render(request,'auth_fail.html')
> else:
> return render(request,'auth_success.html')*
>
> This is always returning not authenticated. When I print request.user, it 
> shows AnonymousUser. But, when i print request.COOKIES, i can see the 
> sessionid which was set by the login method from django.contrib.auth.
>
> So, my question is how can I check if the custom user is authenticated or 
> not?. 
> Thanks in advance.
>
> Best Regards,
> Goose. 
>
>

-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/groups/opt_out.




request.user returning AnonymousUser

2013-07-19 Thread l33t

Hello,

I have a custom authentication backend and a custom user model. The 
authentication() method in the custom authentication backend returns the 
custom user after successful authentication. Once authenticated, I use 
login from django.contrib.auth to set the sessionid for the custom user.
Now, I create a method as shown below:
*
def myview(request):
if not request.user.is_authenticated():
return render(request,'auth_fail.html')
else:
return render(request,'auth_success.html')*

This is always returning not authenticated. When I print request.user, it 
shows AnonymousUser. But, when i print request.COOKIES, i can see the 
sessionid which was set by the login method from django.contrib.auth.

So, my question is how can I check if the custom user is authenticated or 
not?. 
Thanks in advance.

Best Regards,
Goose. 

-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/groups/opt_out.