예제 #1
0
 def get_current_user(self):
     header = self.request.headers.get('AUTHORIZATION')
     if header is None:
         return None
     data = JWTUtil.jwt_decode(header)
     if data is None:
         return None
     user_id = data['user_id']
     device_id = data['device_id']
     try:
         user = User.objects.get(pk=user_id)
         device = RegisteredDevices.objects.get(
             token=device_id,
             is_active=True,
             user=user
         )
     except ObjectDoesNotExist:
         return None
     self.device = device
     return user