fix: authentication dialog

This commit is contained in:
hstyi
2025-02-12 17:32:11 +08:00
committed by hstyi
parent b8d612f1d5
commit d0d51b3e6f

View File

@@ -19,7 +19,7 @@ class RequestAuthenticationDialog(owner: Window) : DialogWrapper(owner) {
private val rememberCheckBox = JCheckBox("Remember") private val rememberCheckBox = JCheckBox("Remember")
private val passwordPanel = JPanel(BorderLayout()) private val passwordPanel = JPanel(BorderLayout())
private val passwordPasswordField = OutlinePasswordField() private val passwordPasswordField = OutlinePasswordField()
private val publicKeyComboBox = FlatComboBox<OhKeyPair>() private val publicKeyComboBox = OutlineComboBox<OhKeyPair>()
private val keyManager get() = KeyManager.getInstance() private val keyManager get() = KeyManager.getInstance()
private var authentication = Authentication.No private var authentication = Authentication.No
@@ -111,6 +111,19 @@ class RequestAuthenticationDialog(owner: Window) : DialogWrapper(owner) {
override fun doOKAction() { override fun doOKAction() {
val type = authenticationTypeComboBox.selectedItem as AuthenticationType 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( authentication = authentication.copy(
type = type, type = type,
password = if (type == AuthenticationType.Password) String(passwordPasswordField.password) password = if (type == AuthenticationType.Password) String(passwordPasswordField.password)