langgenius/dify · error · AccountBannedError

account_banned

account_banned

Error message

Account is banned.

What it means

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.

Source

Thrown at api/controllers/console/auth/login.py:161

                invite_token = None

        try:
            if invitation_data:
                data = invitation_data.get("data", {})
                invitee_email = data.get("email") if data else None
                invitee_email_normalized = invitee_email.lower() if isinstance(invitee_email, str) else invitee_email
                if invitee_email_normalized != normalized_email:
                    _log_console_login_failure(
                        email=normalized_email,
                        reason=LoginFailureReason.INVALID_INVITATION_EMAIL,
                    )
                    raise InvalidEmailError()
            account = _authenticate_account_with_case_fallback(
                request_email, normalized_email, req_data.password, invite_token
            )
        except services.errors.account.AccountLoginError:
            _log_console_login_failure(email=normalized_email, reason=LoginFailureReason.ACCOUNT_BANNED)
            raise AccountBannedError()
        except services.errors.account.AccountPasswordError as exc:
            AccountService.add_login_error_rate_limit(normalized_email)
            _log_console_login_failure(email=normalized_email, reason=LoginFailureReason.INVALID_CREDENTIALS)
            raise AuthenticationFailedError() from exc
        tenants = TenantService.get_join_tenants(account, session=db.session())
        if len(tenants) == 0:
            if (
                FeatureService.is_workspace_creation_allowed()
                and not FeatureService.get_license().workspaces.is_available()
            ):
                raise WorkspacesLimitExceeded()
            else:
                return SimpleResultOptionalDataResponse(
                    result="fail",
                    data="workspace not found, please contact system admin to invite you to join in a workspace",
                ).model_dump(mode="json")

        token_pair = AccountService.login(account=account, session=db.session(), ip_address=extract_remote_ip(request))

View on GitHub (pinned to ef8544b173)

Solutions

  1. Contact the workspace/system administrator to review and unban the account (set account.status back to ACTIVE).
  2. If you are the admin, inspect Account.status and AccountStatus enum in the DB and reset it.
  3. Check audit logs for who/what set the banned status and when.
  4. Have the user clear cookies and retry after the status is restored.

Example fix

-- before: account row has status = 'banned'
-- after: restore active status
UPDATE accounts SET status = 'active' WHERE email = 'user@example.com';
Defensive patterns

Strategy: try-catch

Validate before calling

null

Type guard

null

Try / catch

from controllers.console.error import AccountBannedError
try:
    do_login()
except AccountBannedError:
    direct_user_to_contact_admin('Your account is banned. Contact your administrator.')

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of langgenius/dify@ef8544b173 (2026-08-12). Data as JSON: /api/errors/2fb941a53350b7c4. Report an issue: GitHub.