Repository navigation
Add multi-account support for GitHub.com in GitHub Desktop - #21467
Mahmadabid wants to merge 3 commits into
Conversation
…e account selection This commit introduces support for multiple accounts per endpoint, allowing users to sign in with multiple GitHub.com accounts (e.g., personal and work) simultaneously in Github Desktop. It updates account storage, token isolation, and UI to handle multiple accounts, adds a repository-account preference store, and provides new APIs for precise account lookup. The accounts preferences UI now lists all GitHub.com accounts and allows adding more, and users can select the preferred account for each repository. Comprehensive unit and security tests are included to verify correct behavior and token isolation.
maifeeulasad
left a comment
There was a problem hiding this comment.
so far looks good to me
but, i think
- a detailed test for validating username, user email is correct when switching between account should be done with more care
- shall we group repo per user login??? just a question, asking
| this.reset() | ||
| } | ||
|
|
||
| const existingAccount = this.accounts.find(isDotComAccount) |
There was a problem hiding this comment.
care to explain the updated flow please?
There was a problem hiding this comment.
Previously, beginDotComSignIn would check if a GitHub.com account already existed. If it did, it would transition to SignInStep.ExistingAccountWarning, effectively blocking the user from signing in with a second account unless they signed out of the first one.
The updated flow bypasses this check for GitHub.com. It now transitions directly to SignInStep.Authentication regardless of whether an account is already present. This change is the key enabler for multi-account support, allowing the user to initiate a new OAuth flow and add a second account alongside the existing one without interruption.
| describe('beginDotComSignIn', () => { | ||
| it('starts authentication flow even if accounts exist (multi-account support)', async () => { | ||
| // Setup: Add an existing .com account | ||
| const existingAccount = new Account( |
There was a problem hiding this comment.
care to explain these params please?
There was a problem hiding this comment.
These parameters correspond to the constructor arguments for the Account model defined in app/src/models/account.ts. They are required to create a valid Account instance for the test.
In order, they represent:
- login: The username (e.g., 'existing-user').
- endpoint: The API URL (e.g., 'https://api.github.com/').
- token: The dummy OAuth token.
- emails: List of emails (empty array for this test).
- avatarURL: User's avatar URL (empty string).
- id: Unique user ID (1).
- name: Display name (empty string).
- plan: (Optional) Account plan (e.g., 'free').
I'm manually constructing this mock account to simulate a pre-existing user session in the store before verifying the multi-account sign-in logic
You're right, we should add explicit tests verifying that when switching the preferred account for a repository, the commit author info (username, email) correctly reflects the newly selected account. Regarding grouping repositories per user login: The current design maintains a flat list of repositories where each repo's preferred account is managed via the |
Expanded RepositoryAccountStore tests to cover multi-account switching, ensuring correct association of usernames, emails, and names per repository. Added tests for independent account preferences across repositories and for correct account lookup after switching. Also improved documentation in SignInStore tests for account constructor parameters.
|
Hey @maifeeulasad |
|
Hey @Mahmadabid , I think you take a look into session partion as well. That would be more helpful. Just dropping a link which you may find helpful and resolve some more issues. ref: |
|
Hi @Mahmadabid, thanks for working on this PR and attempting to address this long-standing feature request. After reviewing this, we've decided we need to reserve multi-account support for the internal team. This feature touches critical authentication systems and has many intricate edge cases that require deep coordination with our product, design, and security teams, including: Given the scope and complexity, we need to own this implementation end-to-end to ensure it meets Desktop's quality bar and integrates with our broader roadmap. We're closing this PR but keeping #3707 open to continue tracking this highly-requested feature as we work on our own solution. For future contributions, we recommend checking with the Desktop team before starting work on significant features. Issues marked with |
Multi-Account Support for GitHub Desktop
Description
This PR introduces multi-account support for GitHub.com in GitHub Desktop. Users can now sign in with multiple GitHub accounts simultaneously and associate specific accounts with individual repositories. This ensures that commits and other actions are performed using the correct identity, even when multiple accounts are active.
Key Changes
Core Logic
setRepositoryAccountaction to update preferences and trigger UI refreshes.User Interface
onSetRepositoryAccountcallback through the component tree to enable the account switching interaction.Sign-In Flow
Testing
RepositoryAccountStoreandSignInStoreto verify preference persistence and account addition flows.multi-account-security-test.ts).Fixes #3707