mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-12-24 00:50:28 +00:00
Fix support for upgrading encrypted wikis
Importing an encrypted wiki ordinarily doesn’t place the password in the password vault on the basis that one ought to be able to import from a file without automatically inheriting its password. Now there’s a configuration option that can be used by the upgrade plugin to cause the password vault to be updated with any password entered by the user. The end result is that the user only needs to enter their password once.
This commit is contained in:
parent
85f37a7d35
commit
e40a0c07b8
@ -46,7 +46,17 @@ exports.decryptStoreArea = function(encryptedStoreArea,password) {
|
||||
}
|
||||
};
|
||||
|
||||
exports.decryptStoreAreaInteractive = function(encryptedStoreArea,callback) {
|
||||
|
||||
/*
|
||||
Attempt to extract the tiddlers from an encrypted store area using the current password. If that fails, the user is prompted for a password.
|
||||
encryptedStoreArea: text of the TiddlyWiki encrypted store area
|
||||
callback: function(tiddlers) called with the array of decrypted tiddlers
|
||||
|
||||
The following configuration settings are supported:
|
||||
|
||||
$tw.config.usePasswordVault: causes any password entered by the user to also be put into the system password vault
|
||||
*/
|
||||
exports.decryptStoreAreaInteractive = function(encryptedStoreArea,callback,options) {
|
||||
// Try to decrypt with the current password
|
||||
var tiddlers = $tw.utils.decryptStoreArea(encryptedStoreArea);
|
||||
if(tiddlers) {
|
||||
@ -66,6 +76,9 @@ exports.decryptStoreAreaInteractive = function(encryptedStoreArea,callback) {
|
||||
// Attempt to decrypt the tiddlers
|
||||
var tiddlers = $tw.utils.decryptStoreArea(encryptedStoreArea,data.password);
|
||||
if(tiddlers) {
|
||||
if($tw.config.usePasswordVault) {
|
||||
$tw.crypto.setPassword(data.password);
|
||||
}
|
||||
callback(tiddlers);
|
||||
// Exit and remove the password prompt
|
||||
return true;
|
||||
|
@ -37,11 +37,19 @@ The following tiddlers will be included in the upgrade <$button message="tw-perf
|
||||
|
||||
Upgrade completed. Click the button below to save your upgraded ~TiddlyWiki file
|
||||
|
||||
<$reveal type="match" state="$:/isEncrypted" text="yes">
|
||||
|
||||
The file will be encrypted with your existing password
|
||||
|
||||
</$reveal>
|
||||
|
||||
{{$:/plugins/tiddlywiki/upgrade/save}}
|
||||
|
||||
---
|
||||
Make sure that you keep a safe copy of your previous ~TiddlyWiki file.
|
||||
|
||||
{{$:/snippets/encryptionstatus}}
|
||||
Close this browser window to prevent others from being able to access your data.
|
||||
|
||||
For help and support, visit [[the TiddlyWiki discussion forum|http://groups.google.com/group/TiddlyWiki]].
|
||||
|
||||
</$reveal>
|
||||
|
||||
|
25
plugins/tiddlywiki/upgrade/config.js
Normal file
25
plugins/tiddlywiki/upgrade/config.js
Normal file
@ -0,0 +1,25 @@
|
||||
/*\
|
||||
title: $:/plugins/tiddlywiki/upgrade/config.js
|
||||
type: application/javascript
|
||||
module-type: startup
|
||||
|
||||
Startup module for configuring the upgrade plugin
|
||||
|
||||
\*/
|
||||
(function(){
|
||||
|
||||
/*jslint node: true, browser: true */
|
||||
/*global $tw: false */
|
||||
"use strict";
|
||||
|
||||
// Export name and synchronous status
|
||||
exports.name = "upgrade-config";
|
||||
exports.before = ["startup"];
|
||||
exports.synchronous = true;
|
||||
|
||||
exports.startup = function() {
|
||||
// See $tw.utils.decryptStoreAreaInteractive() in $:/core/modules/utils/crypto.js
|
||||
$tw.config.usePasswordVault = true;
|
||||
};
|
||||
|
||||
})();
|
Loading…
Reference in New Issue
Block a user