Skip to content

Commit 8342872

Browse files
committed
Fix SSO migration from production auth
1 parent df3d5fc commit 8342872

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

packages/core/src/codewhisperer/util/authUtil.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ export class AuthUtil implements IAuthProvider {
149149
this.session = new SsoLogin(this.profileName, this.lspAuth, this.eventEmitter)
150150
await this.session.restore()
151151
if (!this.isConnected()) {
152-
await this.session?.logout()
153152
// Try to restore an IAM session
154153
this.session = new IamLogin(this.profileName, this.lspAuth, this.eventEmitter)
155154
await this.session.restore()
@@ -180,13 +179,15 @@ export class AuthUtil implements IAuthProvider {
180179

181180
// Log in using SSO
182181
async loginSso(startUrl: string, region: string): Promise<GetSsoTokenResult | undefined> {
183-
let response: GetSsoTokenResult | undefined
184182
// Create SSO login session
185183
if (!this.isSsoSession()) {
186184
this.session = new SsoLogin(this.profileName, this.lspAuth, this.eventEmitter)
187185
}
188-
// eslint-disable-next-line prefer-const
189-
response = await (this.session as SsoLogin).login({ startUrl: startUrl, region: region, scopes: amazonQScopes })
186+
const response = await (this.session as SsoLogin).login({
187+
startUrl: startUrl,
188+
region: region,
189+
scopes: amazonQScopes,
190+
})
190191
await showAmazonQWalkthroughOnce()
191192
return response
192193
}
@@ -553,9 +554,10 @@ export class AuthUtil implements IAuthProvider {
553554
scopes: amazonQScopes,
554555
}
555556

556-
if (this.session instanceof SsoLogin) {
557-
await this.session.updateProfile(registrationKey)
557+
if (!this.isSsoSession()) {
558+
this.session = new SsoLogin(this.profileName, this.lspAuth, this.eventEmitter)
558559
}
560+
await (this.session as SsoLogin).updateProfile(registrationKey)
559561

560562
const cacheDir = getCacheDir()
561563

0 commit comments

Comments
 (0)