Create account only for e-mails registred in my external database

I want only registered people on my external website to create an account in my discourse forum. I don’t think that i can use SSO API because my website doesn’t contain authentication, it is just registration in sql database.
Can I perform a condition in the sign up for only registered people in my sql database ( my website) could sign up?

I’m no discourse expert, but there’s many ways of handling this and here’s one I would expect might work and would try to explore:

  1. Require approval for new discourse users
  2. Develop a script in your remote website or a serverless environment that queries your database for a person, and then calls the discourse API to approve/decline the new user
  3. Have discourse make a web hook call to the script when there is a new user
  4. Customise your discourse wording to better describe to your users what is happening

Basically discourse has good webhooks and api, so you can use them while writing your custom script remotely in whatever language your are comfortable in.

If you’re happy to write a discourse plugin in ruby that would work, but personally I’m not so I would fine this easier.

One way to accomplish this would be to enable the invite only and must approve users site settings. With those settings enabled, the only people who will be allowed to create accounts on your site are users who are invited to the site. Invites will only be able to be sent by staff users because the must approve users site setting prevents non-staff users from sending invites.

You could then pull email addresses from your sql database and add those email addresses to a CSV file. That file could be used to bulk invite users by following the steps outlined here: Sending Bulk User Invites.

1 Like

Thanks Jonathan for your idea,
I couldn’t find the API to use to approve or decline the sign up

Thanks Simon,
The problem that the data base is wide and updatable,

Searching the discourse codebase on github, I found an “approve_user” action e.g. put "/review/#{}/perform/approve_user.json". Looks like you might have to get the reviewables first in order to get the reviewalble id you need.