MCPcopy Create free account
hub / github.com/KangLin/RabbitRemoteControl / saveCredentials

Method saveCredentials

Plugins/WebBrowser/PasswordStore.cpp:80–107  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

78}
79
80void CPasswordStore::saveCredentials(
81 const QString &host, const QString &username, const QString &password)
82{
83 if (host.isEmpty() || username.isEmpty()) return;
84
85 const QString key = ServiceName() + QStringLiteral("autofill/%1").arg(host);
86
87 QJsonObject obj;
88 obj.insert(QStringLiteral("username"), username);
89 obj.insert(QStringLiteral("password"), password);
90 const QString payload =
91 QString::fromUtf8(QJsonDocument(obj).toJson(QJsonDocument::Compact));
92 auto pJob = new QKeychain::WritePasswordJob(ServiceName());
93 bool check = connect(pJob, &QKeychain::WritePasswordJob::finished,
94 [this, host, pJob]() {
95 if (pJob->error() != QKeychain::NoError) {
96 qDebug(log) << "Saved credentials error for" << host << ":"
97 << pJob->errorString();
98 return;
99 }
100 emit this->credentialsSaved(host);
101 qDebug(log) << "Saved credentials for" << host;
102 });
103 Q_ASSERT(check);
104 pJob->setKey(key);
105 pJob->setTextData(payload);
106 pJob->start();
107}
108#else
109QVariantMap CPasswordStore::getCredentials(const QString &host)
110{

Callers 1

onSubmitFunction · 0.80

Calls 6

errorStringMethod · 0.80
startMethod · 0.80
SavePasswordMethod · 0.80
ServiceNameFunction · 0.70
isEmptyMethod · 0.45

Tested by

no test coverage detected