Skip to content
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

Create user without password for OAuth2 login #12872

Open
mbrodala opened this issue Dec 6, 2018 · 1 comment
Open

Create user without password for OAuth2 login #12872

mbrodala opened this issue Dec 6, 2018 · 1 comment

Comments

@mbrodala
Copy link
Contributor

mbrodala commented Dec 6, 2018

Is there a way to create users via the REST API (users.create) without password? These users need to be able to log in via a custom OAuth2 provider which doesn't work if a user has a password set.

I know that users are created implicitly upon first login via OAuth2 but in this scenario I don't get the user ID from RocketChat which I need to trigger updates from a foreign system later. That's why my plan is to create users in RocketChat manually before they start using RocketChat.

@mbrodala
Copy link
Contributor Author

mbrodala commented Dec 10, 2018

As a workaround I now manually connect to the MongoDB database of RocketChat and modify the services field of the newly created user. With JavaScript this would look like this:

rocketchat.users.updateOne(
  { _id: user.id },
  {
    $set: {
      services: {
        <custom-oauth2-identifier>: {
          _OAuthCustom: true,
          id: user.username
        }
      }
    }
  }
)

(user.id is the internal user ID within RocketChat, as returned e.g. by the users.create API call. user.username is the ID as returned by my custom OAuth2 service.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant