{"record":{"id":"3d2b74616f79f498","repo":"ruvnet/RuView","slug":"inactive-user","errorCode":null,"errorMessage":"Inactive user","messagePattern":"Inactive user","errorType":"http","errorClass":"HTTPException","httpStatus":403,"severity":"error","filePath":"archive/v1/src/api/dependencies.py","lineNumber":125,"sourceCode":"        ),\n        headers={\"WWW-Authenticate\": \"Bearer\"},\n    )\n\n\nasync def get_current_active_user(\n    current_user: Optional[Dict[str, Any]] = Depends(get_current_user)\n) -> Dict[str, Any]:\n    \"\"\"Get current active user (required authentication).\"\"\"\n    if not current_user:\n        raise HTTPException(\n            status_code=status.HTTP_401_UNAUTHORIZED,\n            detail=\"Authentication required\",\n            headers={\"WWW-Authenticate\": \"Bearer\"},\n        )\n    \n    # Check if user is active\n    if not current_user.get(\"is_active\", True):\n        raise HTTPException(\n            status_code=status.HTTP_403_FORBIDDEN,\n            detail=\"Inactive user\"\n        )\n    \n    return current_user\n\n\nasync def get_admin_user(\n    current_user: Dict[str, Any] = Depends(get_current_active_user)\n) -> Dict[str, Any]:\n    \"\"\"Get current admin user (admin privileges required).\"\"\"\n    if not current_user.get(\"is_admin\", False):\n        raise HTTPException(\n            status_code=status.HTTP_403_FORBIDDEN,\n            detail=\"Admin privileges required\"\n        )\n    \n    return current_user","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/ruvnet/RuView/blob/4685618388a5e49fad5b3005806f3bdd6a7c25c3/archive/v1/src/api/dependencies.py#L107-L143","documentation":"After successful authentication, get_current_active_user raises 403 'Inactive user' when the authenticated user record has is_active=False (defaulting to True when absent). The token itself is valid; the account behind it is disabled.","triggerScenarios":"A deactivated account presenting a still-valid JWT; test fixtures seeding users with is_active=False; an admin toggling is_active off without revoking existing tokens.","commonSituations":"Offboarded user whose long-lived token has not expired; database flips of is_active that outpace token expiry; dev seed data marking users inactive.","solutions":["Re-enable the account (set is_active=True) or have the user authenticate as an active account","Invalidate existing tokens when deactivating a user (short JWT expiry or a denylist)","Fix test fixtures that create users with is_active=False when active users are intended"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# Before relying on a stored account, check its active flag\nimport jwt\ndef account_is_usable(token, verify=False):\n    claims = jwt.decode(token, options={'verify_signature': verify})\n    return claims.get('is_active', True)\nif not account_is_usable(saved_token):\n    saved_token = None  # force re-authentication instead of hitting 403","typeGuard":null,"tryCatchPattern":"try:\n    r = client.get('/api/me', headers=auth)\n    r.raise_for_status()\nexcept httpx.HTTPStatusError as e:\n    if e.response.status_code == 403 and 'Inactive user' in e.response.text:\n        # account disabled: stop retrying, prompt for support/other account\n        logout()\n    raise","preventionTips":["Keep JWT lifetimes short so deactivation takes effect quickly","Revoke tokens as part of the user-deactivation workflow","Treat 403 'Inactive user' as terminal for the session — do not retry"],"tags":["authentication","authorization","http-403","python"],"backgroundTag":null,"analyzedSha":"4685618388a5e49fad5b3005806f3bdd6a7c25c3","analyzedAt":"2026-08-16T06:09:40.886Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}