1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-11-03 17:13:05 +00:00

Do the right thing when we have a username but no password

With a username parameter but no password parameter we'll attribute edits to that username, but not require authentication.
This commit is contained in:
Jermolene
2018-06-26 15:40:29 +01:00
parent 501d0a8edc
commit bdb68fea6d
2 changed files with 4 additions and 3 deletions

View File

@@ -19,7 +19,7 @@ exports.path = /^\/status$/;
exports.handler = function(request,response,state) {
response.writeHead(200, {"Content-Type": "application/json"});
var text = JSON.stringify({
username: state.authenticatedUsername,
username: state.authenticatedUsername || state.server.get("username") || "",
space: {
recipe: "default"
},

View File

@@ -43,9 +43,10 @@ function Server(options) {
}
$tw.utils.extend({},this.defaultVariables,options.variables);
// Initialise authorization
var authorizedUserName = (this.get("username") && this.get("password")) ? this.get("username") : "(anon)";
this.authorizationPrincipals = {
readers: (this.get("readers") || this.get("username") || "(anon)").split(",").map($tw.utils.trim),
writers: (this.get("writers") || this.get("username") || "(anon)").split(",").map($tw.utils.trim)
readers: (this.get("readers") || authorizedUserName).split(",").map($tw.utils.trim),
writers: (this.get("writers") || authorizedUserName).split(",").map($tw.utils.trim)
}
// Load and initialise authenticators
$tw.modules.forEachModuleOfType("authenticator", function(title,authenticatorDefinition) {