diff --git a/fyle_rest_auth/helpers.py b/fyle_rest_auth/helpers.py index 3206f99..b30aca2 100644 --- a/fyle_rest_auth/helpers.py +++ b/fyle_rest_auth/helpers.py @@ -1,3 +1,5 @@ +import logging +import traceback from typing import Dict from rest_framework.exceptions import ValidationError @@ -13,6 +15,9 @@ auth = AuthUtils() +logger = logging.getLogger(__name__) +logger.level = logging.INFO + def validate_code_and_login(request): authorization_code = request.data.get('code') @@ -53,7 +58,12 @@ def validate_code_and_login(request): return tokens + except ValidationError as error: + logger.info(error) + raise + except Exception as error: + logger.error(traceback.format_exc()) raise ValidationError(error) @@ -103,7 +113,12 @@ def validate_refresh_token_and_login(request): return tokens + except ValidationError as error: + logger.info(error) + raise + except Exception as error: + logger.error(traceback.format_exc()) raise ValidationError(error) @@ -135,7 +150,12 @@ def validate_and_refresh_token(request): return tokens + except ValidationError as error: + logger.info(error) + raise + except Exception as error: + logger.error(traceback.format_exc()) raise ValidationError(error) @@ -166,4 +186,4 @@ def get_fyle_admin(access_token: str, origin_address: str = None) -> Dict: settings.FYLE_REST_AUTH_SERIALIZERS['FYLE_MODULE'] == 'PARTNER_DASHBOARD'): return employee_detail else: - raise Exception('User is not an admin') + raise ValidationError('User is not an admin') diff --git a/setup.py b/setup.py index b14dc7d..d2719c0 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setuptools.setup( name='fyle-rest-auth', - version='1.4.0', + version='1.5.0', author='Shwetabh Kumar', author_email='shwetabh.kumar@fyle.in', description='Django application to implement OAuth 2.0 using Fyle in Django rest framework',