Skip to content

Commit

Permalink
decode token added + id made editable
Browse files Browse the repository at this point in the history
  • Loading branch information
abhishm20 committed Jun 8, 2024
1 parent 8d8fd56 commit ad7918b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion drf_misc/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def delete(self):


class AbstractModel(_DateTimeStampingModel):
id = models.CharField(editable=False, unique=True, primary_key=True, max_length=50)
id = models.CharField(unique=True, primary_key=True, max_length=50)

class Meta:
abstract = True
10 changes: 10 additions & 0 deletions drf_misc/utility/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from collections import OrderedDict
from itertools import tee

import jwt
from unidecode import unidecode # pylint: disable=import-error

from drf_misc.core.api_exceptions import BadRequest
Expand Down Expand Up @@ -156,3 +157,12 @@ def log_api_call(name, url, method, payload, headers, response, service_name):
},
response.status_code,
)


def decode_jwt(token):
try:
return True, jwt.decode(token, options={"verify_signature": False})
except Exception as error:
if app_settings.app_logger:
app_settings.app_logger.exception(error)
return False, "Authentication failed"

0 comments on commit ad7918b

Please sign in to comment.