Skip to content
This repository was archived by the owner on Oct 27, 2025. It is now read-only.
This repository was archived by the owner on Oct 27, 2025. It is now read-only.

[Bug]: Error multiple user found when setting organization id #587

@ArthurHlt

Description

@ArthurHlt

Preflight Checklist

  • I could not find a solution in the documentation, the existing issues or discussions
  • I have joined the ZITADEL chat

Version

No response

Describe the problem caused by this bug

When 2 user have same email address in 2 organizations and we try to login by setting scope urn:zitadel:iam:org:id:<org id> we have the error "Multiple users found."

To reproduce

  1. create a first org
  2. add a user with a random email
  3. create second org
  4. add a user with exact same email as step 2
  5. try login by setting scope urn:zitadel:iam:org:id:<org id> to precisely select the wanted org

Screenshots

example with a curl request i've made:

☁ curl 'https://login.saas-office.io/ui/v2/login/loginname?requestId=oidc_V2_335268004772203028^&organization=321701383159940852' \
  -X POST \
  //[ ...]
  --data-raw '[{"loginName":"arthur.halet@saas-office.com","organization":"321701383159940852","requestId":"oidc_V2_335268004772203028","suffix":"$undefined"}]'
0:{"a":"$@1","f":"","b":"C951oDh4qF5LY-oeWKSBp"}
1:{"error":"Multiple users found."}

Expected behavior

I want the exact same behavior as login v1 which take user from the requested org

Relevant Configuration

No response

Additional Context

I've looked at the code and this part seems in cause, it build a queries but it is never used during search. By the way queries is set at the beginning of this function but it is never used.

simply change this code:

    queries.push(
      create(SearchQuerySchema, {
        query: {
          case: "organizationIdQuery",
          value: {
            organizationId,
          },
        },
      }),
    );

to

    emailAndPhoneQueries.push(
      create(SearchQuerySchema, {
        query: {
          case: "organizationIdQuery",
          value: {
            organizationId,
          },
        },
      }),
    );

should fix but it currently heavy work to me to setup everything to test this code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions