[plasma/ksshaskpass] src: Delete password when remember is unchecked
Kai Uwe Broulik <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit 0b8348a4028e6510274e713fb7a97fb0c8a0865d by Kai Uwe Broulik.
Committed on 17/08/2026 at 14:10.
Pushed by broulik into branch 'master'.
Delete password when remember is unchecked
Allows to remove a potentially wrong password from keychain
by unchecking "Remember password".
M +16 -7 src/main.cpp
https://invent.kde.org/plasma/ksshaskpass/-/commit/0b8348a4028e6510274e713fb7a97fb0c8a0865d
diff --git a/src/main.cpp b/src/main.cpp
index 65ec991..088b0a2 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -145,6 +145,8 @@ int main(int argc, char **argv)
return 0;
}
+ std::optional<bool> remember;
+
// Item could not be retrieved from keychain. Open dialog
switch (displayType) {
case DisplayType::ConfirmCancel: {
@@ -219,13 +221,7 @@ int main(int argc, char **argv)
if (dlg.exec() == QDialog::Accepted) {
item = ui.lineEdit->password();
- // If “Enable Keep” is enabled, store the password in keychain
- if ((!identifier.isNull()) && ui.keepCheckBox->isChecked()) {
- QKeychain::WritePasswordJob job(app.applicationName());
- job.setKey(identifier);
- job.setTextData(item);
- execQKeychainJobBlocking(job);
- }
+ remember = ui.keepCheckBox->isChecked();
} else {
// dialog has been canceled
return 1;
@@ -234,6 +230,19 @@ int main(int argc, char **argv)
}
}
+ if (!identifier.isEmpty() && remember.has_value()) {
+ if (remember.value()) {
+ QKeychain::WritePasswordJob job(app.applicationName());
+ job.setKey(identifier);
+ job.setTextData(item);
+ execQKeychainJobBlocking(job);
+ } else {
+ QKeychain::DeletePasswordJob job(app.applicationName());
+ job.setKey(identifier);
+ execQKeychainJobBlocking(job);
+ }
+ }
+
QTextStream out(stdout);
out << item << "\n";
return 0;