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.
This commit is contained in:
Vladimir Krivosheev
2018-05-17 15:37:36 +02:00
parent 058d224c56
commit eb2a9a5182
5 changed files with 25 additions and 24 deletions
@@ -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)
data class CredentialRequestResult(val credentials: Credentials, val isRemember: Boolean)
@@ -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);
}
}
}
@@ -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<*>,
@@ -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
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
@@ -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