@@ -143,6 +143,7 @@ export class Commands {
143
143
const inputUrl = args [ 0 ]
144
144
const inputToken = args [ 1 ]
145
145
const inputLabel = args [ 2 ]
146
+ const isAutologin = typeof args [ 3 ] === "undefined" ? false : Boolean ( args [ 3 ] )
146
147
147
148
const url = await this . maybeAskUrl ( inputUrl )
148
149
if ( ! url ) {
@@ -155,7 +156,7 @@ export class Commands {
155
156
const label = typeof inputLabel === "undefined" ? toSafeHost ( url ) : inputLabel
156
157
157
158
// Try to get a token from the user, if we need one, and their user.
158
- const res = await this . maybeAskToken ( url , inputToken )
159
+ const res = await this . maybeAskToken ( url , inputToken , isAutologin )
159
160
if ( ! res ) {
160
161
return // The user aborted, or unable to auth.
161
162
}
@@ -202,7 +203,11 @@ export class Commands {
202
203
* token. Null means the user aborted or we were unable to authenticate with
203
204
* mTLS (in the latter case, an error notification will have been displayed).
204
205
*/
205
- private async maybeAskToken ( url : string , token : string ) : Promise < { user : User ; token : string } | null > {
206
+ private async maybeAskToken (
207
+ url : string ,
208
+ token : string ,
209
+ isAutologin : boolean ,
210
+ ) : Promise < { user : User ; token : string } | null > {
206
211
const restClient = await makeCoderSdk ( url , token , this . storage )
207
212
if ( ! needToken ( ) ) {
208
213
try {
@@ -212,11 +217,15 @@ export class Commands {
212
217
return { token : "" , user }
213
218
} catch ( err ) {
214
219
const message = getErrorMessage ( err , "no response from the server" )
215
- this . vscodeProposed . window . showErrorMessage ( "Failed to log in" , {
216
- detail : message ,
217
- modal : true ,
218
- useCustom : true ,
219
- } )
220
+ if ( isAutologin ) {
221
+ this . storage . writeToCoderOutputChannel ( `Failed to log in to Coder server: ${ message } ` )
222
+ } else {
223
+ this . vscodeProposed . window . showErrorMessage ( "Failed to log in to Coder server" , {
224
+ detail : message ,
225
+ modal : true ,
226
+ useCustom : true ,
227
+ } )
228
+ }
220
229
// Invalid certificate, most likely.
221
230
return null
222
231
}
0 commit comments