New users via API if allow new unchecked

Hello, I was attempting to setup a new user via the API when I received an error back saying that our hosted version of discourse does “not allow new users at this time”. I discovered that the “allow new registrations” checkbox in the settings section is unchecked.

Was there a way to get around that, other than enabling the checkbox, to have new users created via the API? Something like an override or “force” flag? I am not using “approved”. Will that do what I need or is there something perhaps undocumented? I figure that if I am supplying an API key and API User that is valid, that obviously it is me who is wanting to override that feature.

Thanks!

I have not withdrawn the post. Just looking for an answer is all. :slight_smile:

So I ran a test to see if in fact that setting is the problem and enabled the checkbox to “allow new registrations” and then ran the exact same request and was able to get working. I guess now the question is, is there a way to force a new user being created via the API with that checkbox disabled?

Surely someone has run into something similar where they don’t want just anyone to create an account, but need to be able to create accounts after being fully vetted through some application.

Did you try setting the checkbox to ‘allow new registrations’ but also setting the ‘invite only’ checkbox?

3 Likes

Interesting idea naomi, we have single sign on enabled so I am not sure if the invite only is going to play nice with it. I don’t want invite buttons to pop up everywhere or our support admins to think they need to invite people.

I guess ultimately all I am looking to do is have an SSO implementation (as we have now) with the option to push user accounts into discourse when they sign up or login on the main site. I don’t want them to leave our main site and go to the discourse site and hit “sign in” to have that information “sucked” over and created in discourse.

Does anyone else think that allow new registrations with invite only would work in SSO? I would love to get more thoughts. :slight_smile:

I have SSO as well :slightly_smiling_face: You asked about creating new users via an API call, though, without having just anyone able to create an account. And in that case, you should try my solution.

Invite buttons don’t show when SSO is enabled (Source).

If you have SSO, you don’t need to create users via the API as a correct SSO implementation does it for you (Source).

When you use a separate site as the SSO provider, Discourse will know if they are already logged in and won’t prompt them to sign in again

Here’s one of the resources I used for learning more about how SSO works:

Why not just try it and see if it works for you? :slight_smile:

3 Likes

Thanks again naomi, that is very useful information. I understand that SSO will create the accounts for me, but we are going to need to have those accounts exist in Discourse prior to the user visiting our Discourse site. Based on what I have seen that those accounts are only created when they visit the site and click sign in. At that point it will create the account if it doesn’t already exist using the info from our main site.

But based on what you have said I think it might be enough to implement what we are looking to do. :slight_smile: