-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(authentication_callback): return errors detail instead of generic…
… error 500 (#148)
- Loading branch information
Showing
4 changed files
with
45 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,21 @@ | ||
from django.http import JsonResponse | ||
from django_forest.authentication.exception import BaseAuthenticationException | ||
from django_forest.authentication.exception import BaseAuthenticationException, AuthenticationOpenIdClientException | ||
|
||
|
||
def authentication_exception(f): | ||
def wrapper(*args, **kwargs): | ||
try: | ||
return f(*args, **kwargs) | ||
except AuthenticationOpenIdClientException as error: | ||
return JsonResponse( | ||
{ | ||
"error": error.error, | ||
"error_description": error.error_description, | ||
"state": error.state | ||
}, | ||
status=error.STATUS | ||
) | ||
|
||
except BaseAuthenticationException as error: | ||
return JsonResponse({'errors': [{'detail': str(error)}]}, status=error.STATUS) | ||
return wrapper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters