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

One login integration migrations #10136

Closed
wants to merge 1 commit into from
Closed

Conversation

CatalinVoineag
Copy link
Contributor

@CatalinVoineag CatalinVoineag commented Dec 3, 2024

Context

We want to allow our candidates to login into apply with one login. We also want to allow them to recover their account if their one login email is different from the candidate's email.

These are all the migrations we need for our one login integration, to allow a candidate to login or recover their account.

This is based on the one login spike

Changes proposed in this pull request

We need to allow the user to reclaim their account with any code valid in the last 1 hour for example. That's why AccountRecoveryRequest has_many AccountRecoveryRequestCodes

erDiagram
    Candidate ||--o{ OmniAuthLogin : has_one
    Candidate ||--o{ AccountRecoveryRequest : has_one
    Candidate {
      string email_address
      boolean recovered
      boolean dismiss_recovery
    }
    AccountRecoveryRequest ||--o{ AccountRecoveryRequestCode : has_many
    OmniAuthLogin {
      string token
      string email
      id candidate_id
    }
    AccountRecoveryRequest {
      string previous_account_email
      id candidate
    }
    AccountRecoveryRequestCode {
      string hashed_code
      id account_recovery_request_id
      datetime created_at
    }
Loading

Guidance to review

Does it make sense?

Things to check

  • If the code removes any existing feature flags, a data migration has also been added to delete the entry from the database
  • This code does not rely on migrations in the same Pull Request
  • If this code includes a migration adding or changing columns, it also backfills existing records for consistency
  • If this code adds a column to the DB, decide whether it needs to be in analytics yml file or analytics blocklist
  • If this code adds a column that may include PII, the sanitise.sql script and 0025-protecting-personal-data-in-production-dump.md ADR have been updated.
  • API release notes have been updated if necessary
  • If it adds a significant user-facing change, is it documented in the CHANGELOG?
  • Required environment variables have been updated added to the Azure KeyVault
  • Inform data insights team due to database changes
  • Make sure all information from the Trello card is in here
  • Rebased main
  • Cleaned commit history
  • Tested by running locally
  • Add PR link to Trello card

@CatalinVoineag
Copy link
Contributor Author

These are all the migrations we need for our one login integration, to
allow a candidate to login or recover their account.
class CreateOneLoginAuths < ActiveRecord::Migration[8.0]
def change
create_table :one_login_auths do |t|
t.string :email, null: false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pedantry warning: elsewhere in the code we use 'email_address' rather than 'email'. Can we be consistent?

Copy link
Collaborator

@dcyoung-dev dcyoung-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No idea why the pipeline is failing - looks like you've handled the additional fields 🤷‍♂️

def change
create_table :account_recovery_request_codes do |t|
t.string :hashed_code, null: false
t.index :hashed_code, unique: true
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this has to be unique 🤔 these would work the same as a password - we wouldn't want passwords to be unique

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's true

ActiveRecord::Schema[8.0].define(version: 2024_11_21_144711) do
create_sequence "qualifications_public_id_seq", start: 120000
ActiveRecord::Schema[8.0].define(version: 2024_12_03_151209) do
create_sequence "qualifications_public_id_seq", start: 30690
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this line normally change? Just a bit concerned as it is actually lower than the original start number for the sequence

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😕 I'll put it back how it was

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

Successfully merging this pull request may close these issues.

3 participants