Spaces:
Running
Running
| """Author RAG Chatbot SaaS — Authentication Exceptions.""" | |
| from app.exceptions.base import AppException | |
| class AuthError(AppException): | |
| """Generic authentication failure.""" | |
| def __init__(self, message: str = "Authentication failed") -> None: | |
| super().__init__(message) | |
| class InvalidTokenError(AuthError): | |
| """JWT token is missing, malformed, or has invalid signature.""" | |
| def __init__(self, message: str = "Invalid token") -> None: | |
| super().__init__(message) | |
| class ExpiredTokenError(AuthError): | |
| """JWT token has passed its expiry time.""" | |
| def __init__(self, message: str = "Token has expired") -> None: | |
| super().__init__(message) | |
| class AccountLockedError(AuthError): | |
| """Account is temporarily locked due to too many failed login attempts.""" | |
| def __init__(self, minutes: int = 15) -> None: | |
| super().__init__(f"Account locked. Try again in {minutes} minutes.") | |
| self.lock_minutes = minutes | |
| class InvalidCredentialsError(AuthError): | |
| """Email or password is incorrect.""" | |
| def __init__(self) -> None: | |
| super().__init__("Invalid email or password") | |
| class InsufficientPermissionsError(AuthError): | |
| """User does not have the required role for this action.""" | |
| def __init__(self, required_role: str = "admin") -> None: | |
| super().__init__(f"This action requires {required_role} permissions") | |