29th / personnel-v2

Personnel management system version 2 (legacy)
4 stars 7 forks source link

Link new discourse accounts to existing personnel users #486

Closed wilson29thid closed 3 years ago

wilson29thid commented 3 years ago

The personnel users/members table has a column, forum_member_id. This is used to work out which personnel record a forum session cookie is tied to. When we move to discourse, these will all be wrong because each discourse user will have a new id.

I'm thinking we programmatically create discourse accounts for all active members (using their email address) but not all accounts (there are 23,000 forum accounts in vanilla). The trick, then, will be linking accounts if a former member later signs up to Discourse. This is particularly important if they want to re-enlist.

I'm thinking the way around that is we update all email addresses in the personnel members table from the latest emails in vanilla. Then, when a user signs up to discourse, we just need to check whether there's a record in the personnel members table with that email address, and link it if so.

We could either do this when the user verifies their account in discourse (via a plugin), which would mean we don't even have to import current members, or do it when a user tries to enlist (and maybe have a "link my account" page we tell current members to visit).

Other things to consider:

  1. What about cadets/applicants?
wilson29thid commented 3 years ago

There's now an /associate page that will allow you to associate your new discourse account to your existing personnel account, using the email address you signed up to discourse with (which should be the same one you've been using for Vanilla). It's actually the same page we used when moving to Vanilla - it was still hanging around.

Just got to sort out what to do for people who want to re-enlist and don't know to go to that page.

wilson29thid commented 3 years ago

When a new enlistment is posted, if the forum user that's logged in doesn't already have an associated member account, it will look for an existing member by the email address of the forum account. If it finds one, it will automatically associate it with that forum account. Unless (a) it's already associated with another account, or (b) there are multiple members with that email address. In those two cases, the enlistment throws an error.