Game Dev - User Registration & DB management (advice needed)

Hi folks, hope you’re doing well.

This is just a general ask for help with direction - we’re wanting to use Discourse’s registration / user management / db to register the same details in our external game database (so the player can use the same login details to log into the game).

Currently going through the git repo to get an idea of how things work etc.

The overall plan as mentioned, is when a user registers on the forum, that Discourse will then register the user details in our game database (hosted on another vps). If they update their password or email, that gets reflected in our SQL db, too.

Got a self-hosted Discourse forum up and running already as of a few hours ago, so still learning Discourse atm.

So my question is, is there anywhere we should be looking at first in Discourse to start working on this?

1 Like

The magic words are “DiscourseConnect” and “identity provider” :wink:

4 Likes

Super, thanks for sending this over!

3 Likes

This looks like SSO / DiscouseConnect is needing emails to be validated by a third party.

This is a problem for our particular setup, as we’d like Discourse to handle validating emails and account management as usual, but just pass on the database info to our game DB.

So in essence a reversal of what SSO.

Simply: Discourse needs to handle everything, I just need to get some of the user info from it’s DB.

When you use Discourse as the identity provider as Richard suggested, Discourse will handle email validation for you.

When the user goes through the SSO flow on Discourse and then back to your website, you can use the response that Discourse adds as an embedded query string to the sso param, containing email, username, name, groups, etc (but not password, that would not be a good idea), which you can extract and properly validate using the provided sig.

2 Likes

Hm okay.

So as mentioned its not a website that Discourse will be sending the info to.

Its a game server - aka just a VPS with MySQL running on it.

The old workflow was this:
Unity populates the SQL tables when users “register an account”.

What I’m looking to do is use Discourse as the registration and account management provider.

I.e they register with Discourse and use this info to log in to the game server (through the Unity client).

So I need a way of reliably transfering the Discourse user data to the MySQL database.
(Theyre both on the same machine).

For this we have set up a foreign data wrapper for Postgres → Mysql, and then triggers to populate appropriately.

Then when the user enters their (Discourse) email and password in-game, theyll be able to login - theoretically.

The other issue I have recently read about was the password hashing used by Discourse (which is a good thing for many reasons), but means hashes are unique so cant do that way.

So again, theres no website for the SSO, only Discourse and another VPS running the video game server that clients connect to.