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

Account migrate/merge (experimental only) #1524

Merged
merged 9 commits into from
Aug 4, 2018

Conversation

outoftime
Copy link
Contributor

@outoftime outoftime commented Jul 29, 2018

Sets up a process for migrating an old GitHub-based account into a new Google-based account, merging the data and credentials for the two accounts.

The process is initiated by attempting to link GitHub. If the GitHub account you try to link is already associated with another Firebase account, you’re prompted to merge them:

image

If you choose to proceed, there is a five second grace period during which you can cancel the operation, before anything happens (in case you clicked yes by mistake):

image

After five seconds have passed, the process begins:

image

Once it’s done, you get a success message:

image

Info-level notices are sent to Bugsnag when a migration attempt begins, and when it completes successfully. If there is an error during migration, it is handled by the saga, reported to Bugsnag, and an error message is displayed in the modal.

Currently this feature is only active in experimental mode; once a few people have tested it, we can wide-release it.

If a GitHub identity link fails because the identity is linked to
another account, we dispatch an `ACCOUNT_MIGRATION_NEEDED` action, which
initializes a new `AccountMigration` record in the `PROPOSED` state.
This migration record retains the Firebase credential of the account
that would be merged.

The UI should use the existence of a proposed account migration to
display a model confirming that the user wishes to proceed.
If an attempt to link a GitHub identity requires a merge, display a
modal explaining the situation and asking the user whether they wish to
proceed.

A couple of interesting pieces here:

* We now make a request directly to the GitHub API to retrieve the
  profile of the GitHub account in question, so that we can display its
  avatar and username in the modal.
* As a corollary, the data model for a migration now contains an entire
  (synthetic) `UserAccount` record, including the credential in
  question, rather than just the credential itself.
* There is now a general-purpose `<Modal>` component that displays its
  contents in a modal dialog, which is rendered using a portal. This
  cargo-cults styles from a couple of unmerged PRs, but the
  implementation is new here.
Cancel button issues `DISMISS_ACCOUNT_MIGRATION` which aborts the process
and closes the modal.

Migrate button issues `START_ACCOUNT_MIGRATION`, which sets the state to
a “grace period” during which nothing happens and the user will have the
opportunity to cancel the operation. This currently has no visible
effect.
Creates a second stage of account migration, the `UNDO_GRACE_PERIOD`,
which is a few seconds during which nothing happens and the user has the
opportunity to stop/cancel the migration before it actually begins.

The `<AccountMigration>` component is now more flexible, using the
migration’s state to determine the header copy, and conditionally
showing a different details sub-component for each stage.
@outoftime outoftime force-pushed the account-migrate-merge branch 3 times, most recently from 6105e3e to 274309f Compare August 3, 2018 14:25
Saga initiates account migration, which is fully encapsulated in
Firebase client. Client creates a second SDK instance which is used to
log into the old (GitHub) account using the credential. This instance is
used to retrieve old projects and then save them to the current account.
Then the credential is detached from the old account and attached to the
new one.
…ocess

The saga gives a five-second grace period to click the button to stop
the migration. Now if you click the button before the grace period is
up, the saga exits without doing anything.
We’d like a record of account migrations so that it’s possible to
reconstruct what happens if something goes wrong. Bugsnag has the option
to do an `info`-level severity, which seems reasonably appropriate here,
and more appealing than storing the data in Firebase.
@outoftime outoftime force-pushed the account-migrate-merge branch from 274309f to e8fcf40 Compare August 3, 2018 14:30
@outoftime outoftime changed the title Account migrate/merge Account migrate/merge (experimental only) Aug 4, 2018
@outoftime outoftime merged commit 5be011a into popcodeorg:master Aug 4, 2018
@outoftime outoftime deleted the account-migrate-merge branch August 4, 2018 15:37
return (
<Fragment>
<p>
{t('account-migration.preparing')}

Choose a reason for hiding this comment

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

I'd suggest adding a countdown timer here.

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.

2 participants