diff --git a/tabby-ssh/src/components/keyboardInteractiveAuthPanel.component.ts b/tabby-ssh/src/components/keyboardInteractiveAuthPanel.component.ts index bb2a851d..734aff8c 100644 --- a/tabby-ssh/src/components/keyboardInteractiveAuthPanel.component.ts +++ b/tabby-ssh/src/components/keyboardInteractiveAuthPanel.component.ts @@ -1,4 +1,4 @@ -import { Component, Input, Output, EventEmitter, ViewChild, ElementRef, ChangeDetectionStrategy } from '@angular/core' +import { Component, Input, Output, EventEmitter, ViewChild, ElementRef, ChangeDetectionStrategy, OnInit, ChangeDetectorRef } from '@angular/core' import { KeyboardInteractivePrompt } from '../session/ssh' import { SSHProfile } from '../api' import { PasswordStorageService } from '../services/passwordStorage.service' @@ -9,7 +9,7 @@ import { PasswordStorageService } from '../services/passwordStorage.service' styleUrls: ['./keyboardInteractiveAuthPanel.component.scss'], changeDetection: ChangeDetectionStrategy.OnPush, }) -export class KeyboardInteractiveAuthComponent { +export class KeyboardInteractiveAuthComponent implements OnInit { @Input() profile: SSHProfile @Input() prompt: KeyboardInteractivePrompt @Input() step = 0 @@ -17,7 +17,22 @@ export class KeyboardInteractiveAuthComponent { @ViewChild('input') input: ElementRef remember = false - constructor (private passwordStorage: PasswordStorageService) {} + constructor ( + private passwordStorage: PasswordStorageService, + private cdr: ChangeDetectorRef, + ) {} + + async ngOnInit (): Promise { + const savedPassword = await this.passwordStorage.loadPassword(this.profile) + if (savedPassword) { + for (let i = 0; i < this.prompt.prompts.length; i++) { + if (this.prompt.isAPasswordPrompt(i) && !this.prompt.responses[i]) { + this.prompt.responses[i] = savedPassword + } + } + this.cdr.markForCheck() + } + } isPassword (): boolean { return this.prompt.isAPasswordPrompt(this.step) diff --git a/tabby-ssh/src/session/ssh.ts b/tabby-ssh/src/session/ssh.ts index c25e290d..6756241c 100644 --- a/tabby-ssh/src/session/ssh.ts +++ b/tabby-ssh/src/session/ssh.ts @@ -657,6 +657,10 @@ export class SSHSession { modal.componentInstance.prompt = `Password for ${this.authUsername}@${this.profile.options.host}` modal.componentInstance.password = true modal.componentInstance.showRememberCheckbox = true + const prefilledPassword = await this.passwordStorage.loadPassword(this.profile, this.authUsername) + if (prefilledPassword) { + modal.componentInstance.value = prefilledPassword + } try { const promptResult = await modal.result.catch(() => null)