Skip to content

Adds saving multiple app regs for login. Closes #183 - #854

Draft
Adam-it wants to merge 1 commit into
pnp:devfrom
Adam-it:handles-saving-app-regs
Draft

Adds saving multiple app regs for login. Closes #183#854
Adam-it wants to merge 1 commit into
pnp:devfrom
Adam-it:handles-saving-app-regs

Conversation

@Adam-it

@Adam-it Adam-it commented Jul 30, 2026

Copy link
Copy Markdown
Member

🎯 Aim

The aim of this PR is to allow setting up multiple app regs for multiple tenants and save them in the extension settings. Then, when signing in, the user may pick the app reg by its friendly name from the list of saved app regs. It is also possible to delete one of the saved app regs. The PR does include a migration flow of the existing app reg the user might already have.

📷 Result

Saving app reg friendly name when creating a new app reg
image

The app reg name is visible in te view
image

new setting only editable directly in JSON settings mode
image
image

Deleting one of the saved app regs
image

✅ What was done

  • Added migration flow of existing app reg
  • Added saving app regs for sign in in VS Code extension settings with possibility to provide a friendly name
  • Added a possibility to remove an app reg
  • TODO - I need to recheck the docs, most probably requires some screenshot updates BUT I will perform it once we go over the first review so we ensure I am on the right track here 😉

🔗 Related issue

Closes #183

@Adam-it Adam-it linked an issue Jul 30, 2026 that may be closed by this pull request
@nicodecleyre nicodecleyre self-assigned this Aug 10, 2026

@nicodecleyre nicodecleyre left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Great work so far! Can you take a look at the comment i left? And as you said, let's make the documentation before going for that final review 😉👍

Comment on lines +59 to +66
public static getLastUsed(context: ExtensionContext): AppRegistration | undefined {
const clientId = context.globalState.get<string>(LAST_USED_KEY);
if (!clientId) {
return undefined;
}

return AppRegistrations.getAll().find(item => item.clientId.toLowerCase() === clientId.toLowerCase());
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

setLastUsed stores only clientId and getLastUsed matches only on that. Elsewhere (isSame), a registration is unique on clientId & tenantId. I would suggest to store tenantId in LAST_USED_KEY (as a JSON object) and match on the pair, so that this is consistent with the rest of the class.

@nicodecleyre
nicodecleyre marked this pull request as draft August 11, 2026 21:21
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.

💡 [Feature]: Multiple accounts support

2 participants