Skip to content

Commit 102028a

Browse files
committed
fix: sso logout
1 parent 4e1898d commit 102028a

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/login.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,16 @@ export class Login {
6565
}
6666
}
6767
let auth
68+
const logout = async () => {
69+
if (previousEntry && previousEntry.password) {
70+
try {
71+
await this.logout(previousEntry.password)
72+
delete previousEntry.password
73+
} catch (err) {
74+
ux.warn(err)
75+
}
76+
}
77+
}
6878
switch (input) {
6979
case 'b':
7080
case 'browser':
@@ -76,19 +86,14 @@ export class Login {
7686
break
7787
case 's':
7888
case 'sso':
89+
await logout() // for sso logout first
7990
auth = await this.sso(previousEntry && previousEntry.org)
8091
break
8192
default:
8293
return this.login(opts)
8394
}
8495
await this.saveToken(auth)
85-
if (previousEntry) {
86-
try {
87-
await this.logout(previousEntry.password)
88-
} catch (err) {
89-
ux.warn(err)
90-
}
91-
}
96+
await logout()
9297
} catch (err) {
9398
throw new HerokuAPIError(err)
9499
} finally {

0 commit comments

Comments
 (0)