Skip to content

Commit

Permalink
0.0.9 - update exceptions to catch generic exceptions.
Browse files Browse the repository at this point in the history
  • Loading branch information
garyburgmann committed Feb 3, 2021
1 parent 9d65a81 commit 43c3dbb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
__pycache__/

dist/
build/
dev/

.egg-info
*.egg-info
Expand All @@ -14,4 +16,4 @@ dist/
venv/

# other
README.hidden.md
README.hidden.md
2 changes: 1 addition & 1 deletion drf_firebase_auth/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Metadata for drf-firebase-auth package."""
__title__ = 'drf-firebase-auth'
__version__ = '0.0.9dev1'
__version__ = '0.0.9dev2'
__description__ = (
'Custom Django Rest Framework authentication backend for '
'parsing Firebase uid tokens and storing as local users.'
Expand Down
13 changes: 8 additions & 5 deletions drf_firebase_auth/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@
"""
Authentication backend for handling firebase user.idToken from incoming
Authorization header, verifying, and locally authenticating
Author: Gary Burgmann
Email: garyburgmann@gmail.com
Location: Springfield QLD, Australia
Last update: 2020-05-06
"""
import json
import uuid

import firebase_admin
Expand Down Expand Up @@ -137,6 +132,10 @@ def decode_token(self, firebase_token):
raise exceptions.AuthenticationFailed(
'Token is invalid.'
)
except Exception as e:
raise exceptions.AuthenticationFailed(
f'Exception: {e}'
)

def authenticate_token(self, decoded_token):
"""
Expand All @@ -160,6 +159,10 @@ def authenticate_token(self, decoded_token):
'Error retrieving the user, or the specified user ID does not '
'exist'
)
except Exception as e:
raise exceptions.AuthenticationFailed(
f'Exception: {e}'
)

def get_or_create_local_user(self, firebase_user):
"""
Expand Down

0 comments on commit 43c3dbb

Please sign in to comment.