Browse Source

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

Eugene Pankov 4 years ago
parent
commit
8ff130ebfd

+ 1 - 1
tabby-core/src/api/profileProvider.ts

@@ -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

+ 2 - 4
tabby-local/src/profiles.ts

@@ -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
                 }
             }

+ 1 - 1
tabby-ssh/src/profiles.ts

@@ -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 },

+ 3 - 3
tabby-ssh/src/services/ssh.service.ts

@@ -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)

+ 1 - 1
tabby-ssh/src/session/ssh.ts

@@ -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

+ 1 - 1
tabby-telnet/src/profiles.ts

@@ -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 },