Skip to content

User roles are not assigned when migrating users with bulk import + isVerified field is ignored. #1136

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bizon91 opened this issue Apr 8, 2025 · 2 comments · May be fixed by #1137
Closed
Assignees
Labels
bug Something isn't working

Comments

@bizon91
Copy link

bizon91 commented Apr 8, 2025

🐛 Bug Report

When attempting to migrate users using /bulk-import/import, the roles specified in the userRoles field are ignored. Additionally, even when isVerified is set to false, the response shows the verified field as true

  • Issue 1: The roles defined in the userRoles field are ignored during migration via /bulk-import/import.
  • Issue 2: The isVerified field is set to false in the request, but the response returns verified: true.

Example request:

curl --location --request POST '<supertokens_core_endpoint>/bulk-import/import' \   
     --header 'api-key: *******************' \
     --header 'Content-Type: application/json; charset=utf-8' \
     --data '
    {
      "externalUserId": "test-external-id",
      "userMetadata": {       
        "deviceId": "test-device-id"
      },
      "userRoles": [{ "role": "user", "tenantIds": [] }],
      "loginMethods": [
        {
          "isVerified": false,
          "timeJoinedInMSSinceEpoch": 1551367594480,
          "recipeId": "emailpassword",
          "email": "[email protected]",
          "passwordHash": <password_hash>,
          "hashingAlgorithm": "bcrypt"
        }
      ]
    }
'   

Response:

{"status":"OK","user":{"id":"test-external-id","isPrimaryUser":false,"tenantIds":["public"],"timeJoined":1551367594480,"emails":["[email protected]"],"phoneNumbers":[],"thirdParty":[],"webauthn":{"credentialIds":[]},"loginMethods":[{"tenantIds":["public"],"recipeUserId":"test-external-id","verified":true,"timeJoined":1551367594480,"recipeId":"emailpassword","email":"[email protected]"}]}}

Useful informations

I'm using latest supertokens-docker-mysql image. I don't use multi-tenancy. Role user is already defined.

Image

@bizon91 bizon91 added the bug Something isn't working label Apr 8, 2025
@tamassoltesz tamassoltesz self-assigned this Apr 9, 2025
@tamassoltesz
Copy link
Contributor

tamassoltesz commented Apr 9, 2025

Hi.
For the first issue, I beleive the problem is with your input. Based on your example, you are telling the migration to add the role user on the empty tenant. If you wish to add the role on the public tenant, then you should specify that.

For the second issue, you are right. At first, it was an intentional choice of verifying all emails and the issue was that the isVerified field was even present in the input, but after another round of internal discussions we decided to use that field's value. You can follow the PR's life here: isVerified PR

@bizon91
Copy link
Author

bizon91 commented Apr 10, 2025

Hi.
You're right - when I specified the tenant as public, it worked. However, the specification states that I can simply pass an empty array if I'm not using multi-tenancy.

Image

@bizon91 bizon91 closed this as completed Apr 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants