Uploaded image for project: 'Realm Core'
  1. Realm Core
  2. RCORE-660

Allow creating a user automatically with Credentials.UsernamePassword

      This tripped me up when writing tests for the login functionality and I imagine it'll confuse others as well. Currently, trying to register a user via app.Login(Credentials.UsernamePassword) will fail with 401 and no further information, which means the developer will have to go in the server UI, open the logs, see the error log with content invalid username and guess that this is caused because app.Login only logs the user, but doesn't attempt to create them. This is inconsistent with other credential types as those will create non-existent users (e.g. facebook, google, anonymous).

      While I do realize there's value in enforcing that new users aren't created via app.Login (e.g. fat-fingering a username shouldn't create a new user for you), there's also value in being flexible. That's why I would suggest adding a 3rd optional argument to Credentials.UsernamePassword that will be bool createUser, which will default to false. That way, we use the API itself as a guide for developers that points out that registering and logging in a user are two separate things, while also reducing friction in the beginning.

            Assignee:
            Unassigned Unassigned
            Reporter:
            nikola.irinchev@mongodb.com Nikola Irinchev
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: