Membrane Backend: A centralized authentication service for Single Sign-On (SSO) enabling seamless token-based email verification across multiple client applications.
MIT License
1
stars
0
forks
source link
Refactor app.py for Enhanced Error Handling and JWT Processing #10
We've identified several areas within app.py that can benefit from refactoring for improved error handling, JWT token processing, and overall code maintainability.
Tasks/Changes Needed:
Consolidate Exception Imports:
Combine and simplify exception handling.
Introduce umbrella exceptions like JWTError and RequestError.
Streamline JWT Token Handling in /login Route:
Merge individual try-except blocks.
Introduce extract_and_validate_request_data function to handle email and redirect URL processing.
Improve Error Responses in /verify_token Route:
Consolidate exception handling for MissingTokenError, InvalidTokenError, and jwt_exceptions.InvalidTokenError.
Ensure error messages are concise and user-friendly.
Refactor Imports:
Remove redundant or unused imports.
Reorganize the remaining imports for clarity.
Add Tests:
Write tests for the new functions and exceptions.
Ensure tests cover edge cases and potential error scenarios.
Description:
We've identified several areas within app.py that can benefit from refactoring for improved error handling, JWT token processing, and overall code maintainability.
Tasks/Changes Needed:
Consolidate Exception Imports:
Streamline JWT Token Handling in /login Route:
Improve Error Responses in /verify_token Route: Consolidate exception handling for MissingTokenError, InvalidTokenError, and jwt_exceptions.InvalidTokenError. Ensure error messages are concise and user-friendly.
Refactor Imports: Remove redundant or unused imports. Reorganize the remaining imports for clarity.
Add Tests: Write tests for the new functions and exceptions. Ensure tests cover edge cases and potential error scenarios.