@@ -185,7 +185,6 @@ class DialogUi(
185
185
isRetry : Boolean ,
186
186
useExisting : Boolean ,
187
187
): Pair <String , Source >? {
188
- var (existingToken, tokenSource) = token ? : Pair (" " , Source .USER )
189
188
val getTokenUrl = url.withPath(" /login?redirect=%2Fcli-auth" )
190
189
191
190
// On the first run either open a browser to generate a new token
@@ -199,7 +198,7 @@ class DialogUi(
199
198
// Look on disk in case we already have a token, either in
200
199
// the deployment's config or the global config.
201
200
val tryToken = settings.token(url)
202
- if (tryToken != null && tryToken.first != existingToken ) {
201
+ if (tryToken != null && tryToken.first != token?.first ) {
203
202
return tryToken
204
203
}
205
204
}
@@ -212,29 +211,19 @@ class DialogUi(
212
211
title = " Session Token" ,
213
212
description = if (isRetry) {
214
213
" This token was rejected by ${url.host} ."
215
- } else if (tokenSource == Source .CONFIG ) {
216
- " This token was pulled from your global CLI config."
217
- } else if (tokenSource == Source .DEPLOYMENT_CONFIG ) {
218
- " This token was pulled from your CLI config for ${url.host} ."
219
- } else if (tokenSource == Source .LAST_USED ) {
220
- " This token was the last used token for ${url.host} ."
221
- } else if (tokenSource == Source .QUERY ) {
222
- " This token was pulled from the Gateway link from ${url.host} ."
223
- } else if (existingToken.isNotBlank()) {
224
- " The last used token for ${url.host} is shown above."
225
214
} else {
226
- " No existing token for ${url.host} found."
215
+ token?.second?.description(" token" , url)
216
+ ? : " No existing token for ${url.host} found."
227
217
},
228
- placeholder = existingToken ,
218
+ placeholder = token?.first ,
229
219
link = Pair (" Session Token:" , getTokenUrl.toString()),
230
220
isError = isRetry,
231
221
)
232
222
if (tokenFromUser.isNullOrBlank()) {
233
223
return null
234
224
}
235
- if (tokenFromUser != existingToken) {
236
- tokenSource = Source .USER
237
- }
238
- return Pair (tokenFromUser, tokenSource)
225
+ // If the user submitted the same token, keep the same source too.
226
+ val source = if (tokenFromUser == token?.first) token.second else Source .USER
227
+ return Pair (tokenFromUser, source)
239
228
}
240
229
}
0 commit comments