mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-01-26 17:06:51 +00:00
44 lines
965 B
JavaScript
44 lines
965 B
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/ShowAnonymousAccessModal",
|
|
text: "yes"
|
|
});
|
|
|
|
// Redirect back to admin page
|
|
response.writeHead(302, {"Location": "/"});
|
|
response.end();
|
|
};
|
|
|
|
}());
|