Re: Authorization not working on production server

2018-12-07 Thread Sidnei Pereira
Did you log in?

Em sexta-feira, 7 de dezembro de 2018 09:21:51 UTC-2, Akash utreja escreveu:
>
> Hi,
> I am building authorization in django framework using python.. The problem 
> is that my code is working fine on local server but when I run the same in 
> production it returns "Anonymous User" 
>
> Am I doing it right?
>
> if request.user.has_perm('auth.access_admin')
> ""whole code""
> else:
>return Response({'error': 'Unauthorized'},
> status=status.HTTP_401_UNAUTHORIZED)
>
> My request.user.has_perm return false because request.user is Anonymous.I 
> also try to return my request.user.username it is also coming 
> blank.Please help me out!
> Thanks
> Akash
>
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a9f26837-c05f-4ba8-a81c-745338c0f8fd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Authorization not working on production server

2018-12-07 Thread Akash utreja
Hi,
I am building authorization in django framework using python.. The problem 
is that my code is working fine on local server but when I run the same in 
production it returns "Anonymous User" 

Am I doing it right?

if request.user.has_perm('auth.access_admin')
""whole code""
else:
   return Response({'error': 'Unauthorized'},
status=status.HTTP_401_UNAUTHORIZED)

My request.user.has_perm return false because request.user is Anonymous.I 
also try to return my request.user.username it is also coming 
blank.Please help me out!
Thanks
Akash

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/cf25f56b-1fc6-45df-bf4b-ba0b01729b04%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.