mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-02-03 20:59:09 +00:00
48 lines
1.0 KiB
JavaScript
48 lines
1.0 KiB
JavaScript
|
/*\
|
||
|
title: $:/plugins/tiddlywiki/multiwikiserver/routes/handlers/post-anon.js
|
||
|
type: application/javascript
|
||
|
module-type: mws-route
|
||
|
|
||
|
POST /admin/anon
|
||
|
|
||
|
\*/
|
||
|
(function() {
|
||
|
|
||
|
/*jslint node: true, browser: true */
|
||
|
/*global $tw: false */
|
||
|
"use strict";
|
||
|
|
||
|
exports.method = "POST";
|
||
|
|
||
|
exports.path = /^\/admin\/anon\/?$/;
|
||
|
|
||
|
exports.bodyFormat = "www-form-urlencoded";
|
||
|
|
||
|
exports.csrfDisable = true;
|
||
|
|
||
|
exports.handler = function(request, response, state) {
|
||
|
// Check if user is authenticated and is admin
|
||
|
if(!state.authenticatedUser || !state.authenticatedUser.isAdmin) {
|
||
|
response.writeHead(401, "Unauthorized", { "Content-Type": "text/plain" });
|
||
|
response.end("Unauthorized");
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
|
||
|
// Update the configuration tiddlers
|
||
|
var wiki = $tw.wiki;
|
||
|
wiki.addTiddler({
|
||
|
title: "$:/config/MultiWikiServer/AllowAnonymousReads",
|
||
|
text: "undefined"
|
||
|
});
|
||
|
wiki.addTiddler({
|
||
|
title: "$:/config/MultiWikiServer/AllowAnonymousWrites",
|
||
|
text: "undefined"
|
||
|
});
|
||
|
|
||
|
// Redirect back to admin page
|
||
|
response.writeHead(302, {"Location": "/"});
|
||
|
response.end();
|
||
|
};
|
||
|
|
||
|
}());
|