fixed #4931 - allow empty username to work with winscp integration

This commit is contained in:
Eugene Pankov 2021-11-20 17:39:10 +01:00
parent 064bcb31d8
commit 8ff130ebfd
No known key found for this signature in database
GPG Key ID: 5896FCBBDD1CF4F4
6 changed files with 9 additions and 11 deletions

View File

@ -44,7 +44,7 @@ export abstract class ProfileProvider<P extends Profile> {
abstract getBuiltinProfiles (): Promise<PartialProfile<P>[]>
abstract getNewTabParameters (profile: PartialProfile<P>): Promise<NewTabParameters<BaseTabComponent>>
abstract getNewTabParameters (profile: P): Promise<NewTabParameters<BaseTabComponent>>
getSuggestedName (profile: PartialProfile<P>): string|null {
return null

View File

@ -45,19 +45,17 @@ export class LocalProfilesService extends ProfileProvider<LocalProfile> {
}))
}
async getNewTabParameters (profile: PartialProfile<LocalProfile>): Promise<NewTabParameters<TerminalTabComponent>> {
async getNewTabParameters (profile: LocalProfile): Promise<NewTabParameters<TerminalTabComponent>> {
profile = deepClone(profile)
if (!profile.options?.cwd) {
if (!profile.options.cwd) {
if (this.app.activeTab instanceof TerminalTabComponent && this.app.activeTab.session) {
profile.options ??= {}
profile.options.cwd = await this.app.activeTab.session.getWorkingDirectory() ?? undefined
}
if (this.app.activeTab instanceof SplitTabComponent) {
const focusedTab = this.app.activeTab.getFocusedTab()
if (focusedTab instanceof TerminalTabComponent && focusedTab.session) {
profile.options ??= {}
profile.options.cwd = await focusedTab.session.getWorkingDirectory() ?? undefined
}
}

View File

@ -73,7 +73,7 @@ export class SSHProfilesService extends ProfileProvider<SSHProfile> {
}]
}
async getNewTabParameters (profile: PartialProfile<SSHProfile>): Promise<NewTabParameters<SSHTabComponent>> {
async getNewTabParameters (profile: SSHProfile): Promise<NewTabParameters<SSHTabComponent>> {
return {
type: SSHTabComponent,
inputs: { profile },

View File

@ -28,8 +28,8 @@ export class SSHService {
return this.detectedWinSCPPath ?? this.config.store.ssh.winSCPPath
}
async getWinSCPURI (profile: SSHProfile, cwd?: string): Promise<string> {
let uri = `scp://${profile.options.user}`
async getWinSCPURI (profile: SSHProfile, cwd?: string, username?: string): Promise<string> {
let uri = `scp://${username ?? profile.options.user}`
const password = await this.passwordStorage.loadPassword(profile)
if (password) {
uri += ':' + encodeURIComponent(password)
@ -43,7 +43,7 @@ export class SSHService {
if (!path) {
return
}
const args = [await this.getWinSCPURI(session.profile)]
const args = [await this.getWinSCPURI(session.profile, undefined, session.authUsername ?? undefined)]
if (session.activePrivateKey) {
args.push('/privatekey')
args.push(session.activePrivateKey)

View File

@ -56,12 +56,12 @@ export class SSHSession extends BaseSession {
agentPath?: string
activePrivateKey: string|null = null
authUsername: string|null = null
private remainingAuthMethods: AuthMethod[] = []
private serviceMessage = new Subject<string>()
private keyboardInteractivePrompt = new Subject<KeyboardInteractivePrompt>()
private keychainPasswordUsed = false
private authUsername: string|null = null
private passwordStorage: PasswordStorageService
private ngbModal: NgbModal

View File

@ -55,7 +55,7 @@ export class TelnetProfilesService extends ProfileProvider<TelnetProfile> {
]
}
async getNewTabParameters (profile: PartialProfile<TelnetProfile>): Promise<NewTabParameters<TelnetTabComponent>> {
async getNewTabParameters (profile: TelnetProfile): Promise<NewTabParameters<TelnetTabComponent>> {
return {
type: TelnetTabComponent,
inputs: { profile },