Discussion:
Authorization not working on production server
(too old to reply)
Akash utreja
2018-12-07 11:21:50 UTC
Permalink
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+***@googlegroups.com.
To post to this group, send email to django-***@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.
Sidnei Pereira
2018-12-07 13:59:58 UTC
Permalink
Did you log in?
Post by 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""
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+***@googlegroups.com.
To post to this group, send email to django-***@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.
Continue reading on narkive:
Loading...