You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-07-16 00:14:34 +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:
@ -79,6 +79,16 @@ describeIfCompatible('services_KeychainService', function() {
|
|||||||
|
|
||||||
// However we should still get it via the Setting class, since it will use the keychain
|
// However we should still get it via the Setting class, since it will use the keychain
|
||||||
expect(Setting.value('sync.5.password')).toBe('password');
|
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) {
|
if (currentValue !== s.value) {
|
||||||
const wasSet = await this.keychainService().setPassword(passwordName, s.value);
|
const wasSet = await this.keychainService().setPassword(passwordName, s.value);
|
||||||
if (wasSet) continue;
|
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) {
|
} catch (error) {
|
||||||
this.logger().error(`Could not set setting on the keychain. Will be saved to database instead: ${s.key}:`, error);
|
this.logger().error(`Could not set setting on the keychain. Will be saved to database instead: ${s.key}:`, error);
|
||||||
|
Reference in New Issue
Block a user