1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-06-15 23:00:36 +02:00

All: Better handling of encrypted data on UI side and prevent modification of encrypted notes

This commit is contained in:
Laurent Cozic
2017-12-14 20:21:36 +00:00
parent 2c608bca3c
commit e9bb5bee9d
9 changed files with 108 additions and 40 deletions

View File

@ -3,6 +3,7 @@ const { Database } = require('lib/database.js');
const Setting = require('lib/models/Setting.js');
const { time } = require('lib/time-utils.js');
const { sprintf } = require('sprintf-js');
const { _ } = require('lib/locale.js');
const moment = require('moment');
class BaseItem extends BaseModel {
@ -540,6 +541,21 @@ class BaseItem extends BaseModel {
await this.db().transactionExecBatch(queries);
}
static displayTitle(item) {
if (!item) return '';
return !!item.encryption_applied ? '🔑 ' + _('Encrypted') : item.title + '';
}
static async save(o, options = null) {
if (!options) options = {};
if (options.userSideValidation === true) {
if (!!o.encryption_applied) throw new Error(_('Encrypted items cannot be modified'));
}
return super.save(o, options);
}
}
BaseItem.encryptionService_ = null;