mirror of
https://github.com/laurent22/joplin.git
synced 2025-02-01 19:15:01 +02:00
All: Fixed setting issue that would cause a password to be saved in plain text in the database, even when the keychain is working
This commit is contained in:
parent
b125a768b8
commit
03063f1137
@ -79,6 +79,16 @@ describeIfCompatible('services_KeychainService', function() {
|
||||
|
||||
// However we should still get it via the Setting class, since it will use the keychain
|
||||
expect(Setting.value('sync.5.password')).toBe('password');
|
||||
|
||||
// Now do it again - because there was a bug that would cause the second attempt to save to the db instead
|
||||
Setting.setValue('sync.5.username', 'john');
|
||||
await Setting.saveAll();
|
||||
|
||||
{
|
||||
// Check that it's been removed from the database
|
||||
const row = await db().selectOne('SELECT * FROM settings WHERE key = "sync.5.password"');
|
||||
expect(row).toBe(undefined);
|
||||
}
|
||||
}));
|
||||
|
||||
});
|
||||
|
@ -1318,6 +1318,11 @@ class Setting extends BaseModel {
|
||||
if (currentValue !== s.value) {
|
||||
const wasSet = await this.keychainService().setPassword(passwordName, s.value);
|
||||
if (wasSet) continue;
|
||||
} else {
|
||||
// The value is already in the keychain - so nothing to do
|
||||
// Make sure to `continue` here otherwise it will save the password
|
||||
// in clear text in the database.
|
||||
continue;
|
||||
}
|
||||
} catch (error) {
|
||||
this.logger().error(`Could not set setting on the keychain. Will be saved to database instead: ${s.key}:`, error);
|
||||
|
Loading…
x
Reference in New Issue
Block a user