Re: write custom decorators in django to authenticate the user

2017-11-02 Thread yves . mueller
Can you post an example of how you are using the decorator? If you are using it on a dispatch/get/post ... method of a class based views, it will still get the instance (self) as a first parameter. So you should take also self as an argument to your inner wrap method. Unrelated: Your wrap metho

Re: write custom decorators in django to authenticate the user

2017-11-01 Thread rohit . autosoft
On Thursday, 2 November 2017 09:53:33 UTC+5:30, rohit.a...@gmail.com wrote: > > def authenticated(f): > def wrap(request, *args, **kwargs): > token = request.META.get('HTTP_AUTHORIZATION') > entry = Person.objects.get(pk=kwargs['entry_id']) > payload = jwt.decode(token, SECRET) > user = Person.ob

write custom decorators in django to authenticate the user

2017-11-01 Thread rohit . autosoft
def authenticated(f): def wrap(request, *args, **kwargs): token = request.META.get('HTTP_AUTHORIZATION') entry = Person.objects.get(pk=kwargs['entry_id']) payload = jwt.decode(token, SECRET) user = Person.objects.get( username=payload.get('username'), pk=payload.get('id')) wrap.__doc__=f.__doc__ w