Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3520710

Browse files
authored
Suppress login failure dialog on autologin (#409)
1 parent34faac3 commit3520710

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

‎src/commands.ts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ export class Commands {
143143
constinputUrl=args[0]
144144
constinputToken=args[1]
145145
constinputLabel=args[2]
146+
constisAutologin=typeofargs[3]==="undefined" ?false :Boolean(args[3])
146147

147148
consturl=awaitthis.maybeAskUrl(inputUrl)
148149
if(!url){
@@ -155,7 +156,7 @@ export class Commands {
155156
constlabel=typeofinputLabel==="undefined" ?toSafeHost(url) :inputLabel
156157

157158
// Try to get a token from the user, if we need one, and their user.
158-
constres=awaitthis.maybeAskToken(url,inputToken)
159+
constres=awaitthis.maybeAskToken(url,inputToken,isAutologin)
159160
if(!res){
160161
return// The user aborted, or unable to auth.
161162
}
@@ -202,7 +203,11 @@ export class Commands {
202203
* token. Null means the user aborted or we were unable to authenticate with
203204
* mTLS (in the latter case, an error notification will have been displayed).
204205
*/
205-
privateasyncmaybeAskToken(url:string,token:string):Promise<{user:User;token:string}|null>{
206+
privateasyncmaybeAskToken(
207+
url:string,
208+
token:string,
209+
isAutologin:boolean,
210+
):Promise<{user:User;token:string}|null>{
206211
constrestClient=awaitmakeCoderSdk(url,token,this.storage)
207212
if(!needToken()){
208213
try{
@@ -212,11 +217,15 @@ export class Commands {
212217
return{token:"", user}
213218
}catch(err){
214219
constmessage=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+
}
220229
// Invalid certificate, most likely.
221230
returnnull
222231
}

‎src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
221221
if(cfg.get("coder.autologin")===true){
222222
constdefaultUrl=cfg.get("coder.defaultUrl")||process.env.CODER_URL
223223
if(defaultUrl){
224-
vscode.commands.executeCommand("coder.login",defaultUrl)
224+
vscode.commands.executeCommand("coder.login",defaultUrl,undefined,undefined,"true")
225225
}
226226
}
227227
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp