{"record":{"id":"2fb941a53350b7c4","repo":"langgenius/dify","slug":"account-banned","errorCode":"account_banned","errorMessage":"Account is banned.","messagePattern":"Account is banned\\.","errorType":"error_code","errorClass":"AccountBannedError","httpStatus":400,"severity":"error","filePath":"api/controllers/console/auth/login.py","lineNumber":161,"sourceCode":"                invite_token = None\n\n        try:\n            if invitation_data:\n                data = invitation_data.get(\"data\", {})\n                invitee_email = data.get(\"email\") if data else None\n                invitee_email_normalized = invitee_email.lower() if isinstance(invitee_email, str) else invitee_email\n                if invitee_email_normalized != normalized_email:\n                    _log_console_login_failure(\n                        email=normalized_email,\n                        reason=LoginFailureReason.INVALID_INVITATION_EMAIL,\n                    )\n                    raise InvalidEmailError()\n            account = _authenticate_account_with_case_fallback(\n                request_email, normalized_email, req_data.password, invite_token\n            )\n        except services.errors.account.AccountLoginError:\n            _log_console_login_failure(email=normalized_email, reason=LoginFailureReason.ACCOUNT_BANNED)\n            raise AccountBannedError()\n        except services.errors.account.AccountPasswordError as exc:\n            AccountService.add_login_error_rate_limit(normalized_email)\n            _log_console_login_failure(email=normalized_email, reason=LoginFailureReason.INVALID_CREDENTIALS)\n            raise AuthenticationFailedError() from exc\n        tenants = TenantService.get_join_tenants(account, session=db.session())\n        if len(tenants) == 0:\n            if (\n                FeatureService.is_workspace_creation_allowed()\n                and not FeatureService.get_license().workspaces.is_available()\n            ):\n                raise WorkspacesLimitExceeded()\n            else:\n                return SimpleResultOptionalDataResponse(\n                    result=\"fail\",\n                    data=\"workspace not found, please contact system admin to invite you to join in a workspace\",\n                ).model_dump(mode=\"json\")\n\n        token_pair = AccountService.login(account=account, session=db.session(), ip_address=extract_remote_ip(request))","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/langgenius/dify/blob/ef8544b173fd6cd7a8e71df2cab576e52bebbfbc/api/controllers/console/auth/login.py#L143-L179","documentation":"Raised in POST /console/api/login (HTTP 400, code account_banned) when _authenticate_account_with_case_fallback raises services.errors.account.AccountLoginError, which propagates from AccountService.authenticate when the account status is AccountStatus.BANNED. The controller catches AccountLoginError and re-raises as the console-facing AccountBannedError.","triggerScenarios":"POST /console/api/login with valid credentials for an account whose status column equals AccountStatus.BANNED. The banned status is set by an admin or by automated moderation.","commonSituations":"Account suspended by an admin for policy violation; automated anti-abuse system banned the account; status manually flipped in the DB during incident response; stale session after the account was banned while logged in elsewhere.","solutions":["Contact the workspace/system administrator to review and unban the account (set account.status back to ACTIVE).","If you are the admin, inspect Account.status and AccountStatus enum in the DB and reset it.","Check audit logs for who/what set the banned status and when.","Have the user clear cookies and retry after the status is restored."],"exampleFix":"-- before: account row has status = 'banned'\n-- after: restore active status\nUPDATE accounts SET status = 'active' WHERE email = 'user@example.com';","handlingStrategy":"try-catch","validationCode":"null","typeGuard":"null","tryCatchPattern":"from controllers.console.error import AccountBannedError\ntry:\n    do_login()\nexcept AccountBannedError:\n    direct_user_to_contact_admin('Your account is banned. Contact your administrator.')","preventionTips":["Surface a clear 'account banned' message and a support contact.","Audit Account.status changes to attribute bans.","After unbanning, clear any stale session cookies that may carry old auth state."],"tags":["auth","login","account","banned","authorization"],"backgroundTag":null,"analyzedSha":"ef8544b173fd6cd7a8e71df2cab576e52bebbfbc","analyzedAt":"2026-08-12T05:15:17.394Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}