Commit b279882a authored by Méven Car's avatar Méven Car
Browse files

Check values have changed before setting the model

Summary:
Only save data that needs to be saved and use sanitized data rather than raw text field input.

BUG: 384894
FIXED-IN: 5.18

Test Plan:
Edit Username -> have a PolicyKit password verification
Edit Avatar -> no more password verification popup

Reviewers: #plasma, ngraham, davidedmundson

Reviewed By: #plasma, ngraham, davidedmundson

Subscribers: ngraham, apol, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D25398
parent a6f37349
......@@ -141,19 +141,24 @@ bool AccountInfo::save()
qCDebug(USER_MANAGER_LOG) << "Saving on Index: " << m_index.row();
QList<AccountModel::Role> failed;
if (!m_model->setData(m_index, m_info->username->text(), AccountModel::Username)) {
if (m_infoToSave.contains(AccountModel::Username) &&
!m_model->setData(m_index, m_infoToSave[AccountModel::Username], AccountModel::Username)) {
failed.append(AccountModel::Username);
}
if (!m_model->setData(m_index, m_info->realName->text(), AccountModel::RealName)) {
if (m_infoToSave.contains(AccountModel::RealName) &&
!m_model->setData(m_index, m_infoToSave[AccountModel::RealName], AccountModel::RealName)) {
failed.append(AccountModel::RealName);
}
if (!m_model->setData(m_index, m_info->email->text(), AccountModel::Email)) {
if (m_infoToSave.contains(AccountModel::Email) &&
!m_model->setData(m_index, m_infoToSave[AccountModel::Email], AccountModel::Email)) {
failed.append(AccountModel::Email);
}
if (!m_model->setData(m_index, m_info->administrator->isChecked(), AccountModel::Administrator)) {
if (m_infoToSave.contains(AccountModel::Administrator) &&
!m_model->setData(m_index, m_info->administrator->isChecked(), AccountModel::Administrator)) {
failed.append(AccountModel::Administrator);
}
if (!m_model->setData(m_index, m_info->automaticLogin->isChecked(), AccountModel::AutomaticLogin)) {
if (m_infoToSave.contains(AccountModel::AutomaticLogin) &&
!m_model->setData(m_index, m_info->automaticLogin->isChecked(), AccountModel::AutomaticLogin)) {
failed.append(AccountModel::AutomaticLogin);
}
if (m_infoToSave.contains(AccountModel::Password)) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment