From eb2a9a5182de28319e6281bd513ee261f0f2e5aa Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Thu, 17 May 2018 15:34:52 +0200 Subject: [PATCH] IDEA-191264 Remember" checkbox should be shown always regardless of password safe settings memory only store means that password is stored until restart, but unchecked "Remember" checkbox means "do not remember my password now", so, we must show this checkbox. --- .../credentialStore/credentialPromt.kt | 34 +++++++------------ .../ui/PasswordPromptComponent.java | 9 ++++- .../ui/PasswordSafePromptDialog.kt | 1 + .../platform-resources/src/brokenPlugins.txt | 3 +- .../commands/GitHttpGuiAuthenticator.java | 2 +- 5 files changed, 25 insertions(+), 24 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/credentialStore/credentialPromt.kt b/platform/platform-impl/src/com/intellij/credentialStore/credentialPromt.kt index b56304427e62..79ddc436f8ba 100644 --- a/platform/platform-impl/src/com/intellij/credentialStore/credentialPromt.kt +++ b/platform/platform-impl/src/com/intellij/credentialStore/credentialPromt.kt @@ -37,7 +37,7 @@ fun askPassword(project: Project?, isCheckExistingBeforeDialog = true)?.credentials?.getPasswordAsString()?.nullize() } -internal object RememberCheckBoxState { +object RememberCheckBoxState { private const val key = "checkbox.remember.password" private const val defaultValue = true @@ -66,27 +66,20 @@ fun askCredentials(project: Project?, } else if (isCheckExistingBeforeDialog) { store.get(attributes)?.let { - return CredentialRequestResult(it, false, true) + return CredentialRequestResult(it, false) } } return invokeAndWaitIfNeed(ModalityState.any()) { val passwordField = JPasswordField() - val rememberCheckBox = if (store.isMemoryOnly) { - null - } - else { - CheckBox(CommonBundle.message("checkbox.remember.password"), - selected = RememberCheckBoxState.isSelected, - toolTip = "The password will be stored between application sessions.") - } + val rememberCheckBox = CheckBox(CommonBundle.message("checkbox.remember.password"), + selected = RememberCheckBoxState.isSelected, + toolTip = "The password will be stored between application sessions.") val panel = panel { row { label(if (passwordFieldLabel.endsWith(":")) passwordFieldLabel else "$passwordFieldLabel:") } row { passwordField() } - rememberCheckBox?.let { - row { it() } - } + row { rememberCheckBox() } } AppIcon.getInstance().requestAttention(project, true) @@ -94,18 +87,17 @@ fun askCredentials(project: Project?, return@invokeAndWaitIfNeed null } - if (rememberCheckBox != null) { - RememberCheckBoxState.update(rememberCheckBox) - } + RememberCheckBoxState.update(rememberCheckBox) - val isMemoryOnly = store.isMemoryOnly || !rememberCheckBox!!.isSelected val credentials = Credentials(attributes.userName, passwordField.password.nullize()) - if (isSaveOnOk) { - store.set(attributes, credentials, isMemoryOnly) + if (isSaveOnOk && rememberCheckBox.isSelected) { + store.set(attributes, credentials) credentials.getPasswordAsString() } - return@invokeAndWaitIfNeed CredentialRequestResult(credentials, isMemoryOnly, false) + + // for memory only store isRemember is true, because false doesn't matter + return@invokeAndWaitIfNeed CredentialRequestResult(credentials, isRemember = rememberCheckBox.isSelected) } } -data class CredentialRequestResult(val credentials: Credentials, val isMemoryOnly: Boolean, val isSaved: Boolean) \ No newline at end of file +data class CredentialRequestResult(val credentials: Credentials, val isRemember: Boolean) \ No newline at end of file diff --git a/platform/platform-impl/src/com/intellij/ide/passwordSafe/ui/PasswordPromptComponent.java b/platform/platform-impl/src/com/intellij/ide/passwordSafe/ui/PasswordPromptComponent.java index 682dfd2fd647..7930dd5dd141 100644 --- a/platform/platform-impl/src/com/intellij/ide/passwordSafe/ui/PasswordPromptComponent.java +++ b/platform/platform-impl/src/com/intellij/ide/passwordSafe/ui/PasswordPromptComponent.java @@ -1,6 +1,7 @@ // Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.ide.passwordSafe.ui; +import com.intellij.credentialStore.RememberCheckBoxState; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.text.StringUtil; import com.intellij.util.ui.UIUtil; @@ -38,7 +39,7 @@ public class PasswordPromptComponent { myRememberCheckBox.setSelected(false); } else { - myRememberCheckBox.setSelected(false); // do not force people to un-check this every time! + myRememberCheckBox.setSelected(RememberCheckBoxState.INSTANCE.isSelected()); myRememberCheckBox.setToolTipText("The password will be stored between application sessions."); } @@ -80,4 +81,10 @@ public class PasswordPromptComponent { public boolean isRememberSelected() { return myRememberCheckBox.isSelected(); } + + public void updateRememberState() { + if (myRememberCheckBox.isEnabled()) { + RememberCheckBoxState.INSTANCE.update(myRememberCheckBox); + } + } } diff --git a/platform/platform-impl/src/com/intellij/ide/passwordSafe/ui/PasswordSafePromptDialog.kt b/platform/platform-impl/src/com/intellij/ide/passwordSafe/ui/PasswordSafePromptDialog.kt index cf8748ef4885..b91a969eb808 100644 --- a/platform/platform-impl/src/com/intellij/ide/passwordSafe/ui/PasswordSafePromptDialog.kt +++ b/platform/platform-impl/src/com/intellij/ide/passwordSafe/ui/PasswordSafePromptDialog.kt @@ -10,6 +10,7 @@ object PasswordSafePromptDialog { @Deprecated("Use {@link CredentialPromptDialog}", ReplaceWith("askPassword(project, title, message, CredentialAttributes(requestor, key), resetPassword, error)", "com.intellij.credentialStore.askPassword", "com.intellij.credentialStore.CredentialAttributes")) + @JvmStatic fun askPassword(project: Project?, title: String, message: String, requestor: Class<*>, diff --git a/platform/platform-resources/src/brokenPlugins.txt b/platform/platform-resources/src/brokenPlugins.txt index 3d9de0614d8a..6e333284ca0e 100644 --- a/platform/platform-resources/src/brokenPlugins.txt +++ b/platform/platform-resources/src/brokenPlugins.txt @@ -96,4 +96,5 @@ com.javils.ThemeSwitcher 1.0 1.1 1.2 org.ziglang 0.0.3 com.intellij.aspectj 0.7 TRTIdea 1.0 -com.intellij.stats.completion 0.0.41 0.0.42 0.0.49 0.0.519 0.0.536 0.0.537 0.0.538 0.1.0 0.1.1 0.1.2 \ No newline at end of file +com.intellij.stats.completion 0.0.41 0.0.42 0.0.49 0.0.519 0.0.536 0.0.537 0.0.538 0.1.0 0.1.1 0.1.2 +com.huawei.ide 1.0 \ No newline at end of file diff --git a/plugins/git4idea/src/git4idea/commands/GitHttpGuiAuthenticator.java b/plugins/git4idea/src/git4idea/commands/GitHttpGuiAuthenticator.java index e63f2f35c344..72e87c41cd4a 100644 --- a/plugins/git4idea/src/git4idea/commands/GitHttpGuiAuthenticator.java +++ b/plugins/git4idea/src/git4idea/commands/GitHttpGuiAuthenticator.java @@ -105,7 +105,7 @@ class GitHttpGuiAuthenticator implements GitHttpAuthenticator { myWasCancelled = true; return ""; } - myIsMemoryOnly = ThreeState.fromBoolean(result.isMemoryOnly()); + myIsMemoryOnly = ThreeState.fromBoolean(result.isRemember()); myPassword = password; myDataProvider = new BaseGitAuthDataProvider() { @Override