Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
### [Report an Issue](https://github.com/atlassian/atlascode/issues)

## What's new in 3.8.16

### Bug Fixes

- Fixed a bug that prevented authenticated sites from being individually logged out, which caused all sites sharing the same credentials to be logged out

## What's new in 3.8.14

### Bug Fixes
Expand Down
10 changes: 10 additions & 0 deletions src/atlclients/authStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,16 @@ export class CredentialManager implements Disposable {
}
}

/**
* Determines if a site's credential id is shared among other sites
* @param site The site for the credential we want to look up
* @param allSites All sites (`site` will be excluded from the search)
* @returns True if the credential is shared, false otherwise
*/
public isSiteCredentialShared(site: DetailedSiteInfo, allSites: DetailedSiteInfo[]): boolean {
return !!allSites.find((x) => x !== site && x.credentialId === site.credentialId);
}

/**
* Removes an auth item from both the in-memory store and the secretstorage.
*/
Expand Down
1 change: 1 addition & 0 deletions src/siteManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ describe('SiteManager', () => {
getAuthInfo: jest.fn(),
removeAuthInfo: jest.fn(),
generateCredentialId: jest.fn(),
isSiteCredentialShared: jest.fn().mockReturnValue(false),
} as unknown as CredentialManager;

CredentialManager.generateCredentialId = jest.fn((productKey, userId) => `${productKey}-${userId}`);
Expand Down
9 changes: 8 additions & 1 deletion src/siteManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,14 @@ export class SiteManager extends Disposable {
this.resolvePrimarySite();

if (removeCredentials) {
await Container.credentialManager.removeAuthInfo(deletedSite);
if (
!Container.credentialManager.isSiteCredentialShared(
deletedSite,
this.getSitesAvailable(deletedSite.product),
)
) {
await Container.credentialManager.removeAuthInfo(deletedSite);
}
}
if (fireEvent) {
this._onDidSitesAvailableChange.fire({
Expand Down
Loading