From d0d51b3e6f6075d5fc3ba6d0486ea7c910dbca24 Mon Sep 17 00:00:00 2001 From: hstyi Date: Wed, 12 Feb 2025 17:32:11 +0800 Subject: [PATCH] fix: authentication dialog --- .../app/termora/RequestAuthenticationDialog.kt | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/app/termora/RequestAuthenticationDialog.kt b/src/main/kotlin/app/termora/RequestAuthenticationDialog.kt index e42b99f..78e51a5 100644 --- a/src/main/kotlin/app/termora/RequestAuthenticationDialog.kt +++ b/src/main/kotlin/app/termora/RequestAuthenticationDialog.kt @@ -19,7 +19,7 @@ class RequestAuthenticationDialog(owner: Window) : DialogWrapper(owner) { private val rememberCheckBox = JCheckBox("Remember") private val passwordPanel = JPanel(BorderLayout()) private val passwordPasswordField = OutlinePasswordField() - private val publicKeyComboBox = FlatComboBox() + private val publicKeyComboBox = OutlineComboBox() private val keyManager get() = KeyManager.getInstance() private var authentication = Authentication.No @@ -111,6 +111,19 @@ class RequestAuthenticationDialog(owner: Window) : DialogWrapper(owner) { override fun doOKAction() { val type = authenticationTypeComboBox.selectedItem as AuthenticationType + + if (type == AuthenticationType.Password) { + if (passwordPasswordField.password.isEmpty()) { + passwordPasswordField.requestFocusInWindow() + return + } + } else if (type == AuthenticationType.PublicKey) { + if (publicKeyComboBox.selectedItem == null) { + publicKeyComboBox.requestFocusInWindow() + return + } + } + authentication = authentication.copy( type = type, password = if (type == AuthenticationType.Password) String(passwordPasswordField.password)