mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-01-26 17:06:51 +00:00
Add password handling to server
This commit is contained in:
parent
2b578c5acc
commit
e637b54f36
1
bld.sh
1
bld.sh
@ -8,6 +8,7 @@ echo "five.tiddlywiki.com" > ../../jermolene.github.com/CNAME
|
||||
|
||||
node ../core/boot.js \
|
||||
--verbose \
|
||||
--password password \
|
||||
--savetiddler ReadMe ../readme.md text/html \
|
||||
--savetiddler $:/core/templates/tiddlywiki5.template.html ../../jermolene.github.com/index.html text/plain [!is[shadow]]\
|
||||
--savetiddler $:/core/templates/tiddlywiki5.template.html ../../jermolene.github.com/empty.html text/plain [!is[shadow]is[shadow]]\
|
||||
|
@ -57,11 +57,12 @@ $tw.crypto = new function() {
|
||||
getPassword = function() {
|
||||
if($tw.browser) {
|
||||
password = prompt("Enter password to decrypt TiddlyWiki");
|
||||
} else {
|
||||
password = "password";
|
||||
}
|
||||
};
|
||||
|
||||
this.setPassword = function(newPassword) {
|
||||
password = newPassword;
|
||||
}
|
||||
this.encrypt = function(text) {
|
||||
return callSjcl($tw.crypto.sjcl.encrypt,text);
|
||||
};
|
||||
@ -72,8 +73,6 @@ $tw.crypto = new function() {
|
||||
|
||||
$tw.crypto.sjcl = $tw.browser ? sjcl : require("./sjcl.js");
|
||||
|
||||
console.log("sjcl is " + $tw.crypto.sjcl);
|
||||
|
||||
// Boot information
|
||||
$tw.boot = {};
|
||||
|
||||
|
36
core/modules/commands/password.js
Normal file
36
core/modules/commands/password.js
Normal file
@ -0,0 +1,36 @@
|
||||
/*\
|
||||
title: $:/core/modules/commands/password.js
|
||||
type: application/javascript
|
||||
module-type: command
|
||||
|
||||
Save password for crypto operations
|
||||
|
||||
\*/
|
||||
(function(){
|
||||
|
||||
/*jslint node: true, browser: true */
|
||||
/*global $tw: false */
|
||||
"use strict";
|
||||
|
||||
exports.info = {
|
||||
name: "password",
|
||||
synchronous: true
|
||||
};
|
||||
|
||||
var Command = function(params,commander,callback) {
|
||||
this.params = params;
|
||||
this.commander = commander;
|
||||
this.callback = callback;
|
||||
};
|
||||
|
||||
Command.prototype.execute = function() {
|
||||
if(this.params.length < 1) {
|
||||
return "Missing password";
|
||||
}
|
||||
$tw.crypto.setPassword(this.params[0]);
|
||||
return null;
|
||||
};
|
||||
|
||||
exports.Command = Command;
|
||||
|
||||
})();
|
Loading…
Reference in New Issue
Block a user