make password saving optional (fixes #644)

This commit is contained in:
Eugene Pankov 2019-06-18 23:23:51 +02:00
parent c35c8791f9
commit 77058c0472
3 changed files with 17 additions and 2 deletions

View File

@ -8,3 +8,12 @@
(keyup.enter)='ok()',
(keyup.esc)='cancel()',
)
.d-flex.align-items-start.mt-2
checkbox(
*ngIf='showRememberCheckbox',
[(model)]='remember',
text='Remember'
)
button.btn.btn-primary.ml-auto(
(click)='ok()',
) Enter

View File

@ -8,6 +8,8 @@ import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
export class PromptModalComponent {
@Input() value: string
@Input() password: boolean
@Input() remember: boolean
@Input() showRememberCheckbox: boolean
@ViewChild('input') input: ElementRef
constructor (

View File

@ -192,12 +192,16 @@ export class SSHService {
const modal = this.ngbModal.open(PromptModalComponent)
modal.componentInstance.prompt = `Password for ${session.connection.user}@${session.connection.host}`
modal.componentInstance.password = true
modal.componentInstance.showRememberCheckbox = true
try {
savedPassword = await modal.result
let password = await modal.result
if (modal.componentInstance.remember) {
savedPassword = password
}
return password
} catch (_) {
return ''
}
return savedPassword
})
})