diff --git a/ShhShell/SSH/SSHHandler.swift b/ShhShell/SSH/SSHHandler.swift index 95bc6af..08d79df 100644 --- a/ShhShell/SSH/SSHHandler.swift +++ b/ShhShell/SSH/SSHHandler.swift @@ -66,7 +66,11 @@ class SSHHandler: @unchecked Sendable, ObservableObject { return } - try? authWithNone() + do { + try authWithNone() + } catch { + + } getAuthMethods() if self.host.key != getHostkey() { @@ -74,20 +78,22 @@ class SSHHandler: @unchecked Sendable, ObservableObject { return } - if !host.password.isEmpty { - do { try authWithPw() } catch { - print("pw auth error") - print(error.localizedDescription) - } - } else { - do { - if let publicKey = host.publicKey, - let privateKey = host.privateKey { - try authWithPubkey(pub: publicKey, priv: privateKey, pass: host.passphrase) + if state != .authorized { + if !host.password.isEmpty { + do { try authWithPw() } catch { + print("pw auth error") + print(error.localizedDescription) + } + } else { + do { + if let publicKey = host.publicKey, + let privateKey = host.privateKey { + try authWithPubkey(pub: publicKey, priv: privateKey, pass: host.passphrase) + } + } catch { + print("error with pubkey auth") + print(error.localizedDescription) } - } catch { - print("error with pubkey auth") - print(error.localizedDescription) } } @@ -342,7 +348,6 @@ class SSHHandler: @unchecked Sendable, ObservableObject { return } - //always unknown idk why func getAuthMethods() { var recievedMethod: CInt recievedMethod = ssh_userauth_list(session, nil) diff --git a/ShhShell/Views/Themes/ThemeManagerView.swift b/ShhShell/Views/Themes/ThemeManagerView.swift index 2166ae0..4f57fcb 100644 --- a/ShhShell/Views/Themes/ThemeManagerView.swift +++ b/ShhShell/Views/Themes/ThemeManagerView.swift @@ -18,18 +18,22 @@ struct ThemeManagerView: View { @State var themeToRename: Theme? @State var rename: String = "" - let grid: GridItem = GridItem( - .flexible(minimum: 150, maximum: 250), - spacing: 8, - alignment: .center - ) + var minColWidth: CGFloat {150} + var spacing: CGFloat {8} + var grid: GridItem { + GridItem( + .flexible(minimum: minColWidth, maximum: 250), + spacing: spacing, + alignment: .center + ) + } var body: some View { ZStack { hostsManager.selectedTheme.background.suiColor.opacity(0.7) .ignoresSafeArea(.all) GeometryReader { geo in - let columns: Int = Int(geo.size.width)/200 + let columns: Int = max(1, Int((geo.size.width + 8) / (minColWidth + spacing))) let layout = Array(repeating: grid, count: columns) ScrollView { if hostsManager.themes.isEmpty {