affaan-m/ECC · error · HTTPException
Inactive user
Error message
Inactive user
What it means
Illustrative FastAPI dependency from the fastapi-patterns skill: get_current_active_user wraps get_current_user and rejects a successfully authenticated but deactivated account (is_active false) before route code runs.
Solutions
- Return 403 with a 'inactive account' detail so clients can prompt reactivation
- Audit inactive users periodically and expire their tokens
- Combine with token expiry so reactivation requires re-login
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at skills/fastapi-patterns/SKILL.md:216 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of affaan-m/ECC@d8409a4b08 (2026-08-26).
Data as JSON: /api/errors/7e1981f02acf6620.
Report an issue: GitHub.
Appendix: source
Thrown at skills/fastapi-patterns/SKILL.md:216
payload = jwt.decode(token, settings.secret_key, algorithms=[settings.algorithm])
subject = payload.get("sub")
if subject is None:
raise credentials_exception
user_id = int(subject)
except (JWTError, TypeError, ValueError):
raise credentials_exception
user = await db.get(User, user_id)
if user is None:
raise credentials_exception
return user
async def get_current_active_user(
current_user: Annotated[User, Depends(get_current_user)],
) -> User:
if not current_user.is_active:
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="Inactive user")
return current_user
DbDep = Annotated[AsyncSession, Depends(get_db)]
CurrentUserDep = Annotated[User, Depends(get_current_user)]
ActiveUserDep = Annotated[User, Depends(get_current_active_user)]
```
---
## Router and Endpoint Design
```python
# app/routers/users.py
from typing import Annotated
from fastapi import APIRouter, HTTPException, Query, status
from fastapi.security import OAuth2PasswordRequestForm
View on GitHub (pinned to d8409a4b08)