2024-10-30 18:59:44 +01:00
|
|
|
/*\
|
|
|
|
title: $:/plugins/tiddlywiki/multiwikiserver/routes/handlers/post-role.js
|
|
|
|
type: application/javascript
|
|
|
|
module-type: mws-route
|
|
|
|
|
|
|
|
POST /admin/post-role
|
|
|
|
|
|
|
|
\*/
|
|
|
|
(function () {
|
|
|
|
|
2024-11-08 11:09:42 +01:00
|
|
|
/*jslint node: true, browser: true */
|
|
|
|
/*global $tw: false */
|
|
|
|
"use strict";
|
2024-10-30 18:59:44 +01:00
|
|
|
|
2024-11-08 11:09:42 +01:00
|
|
|
exports.method = "POST";
|
2024-10-30 18:59:44 +01:00
|
|
|
|
2024-11-08 11:09:42 +01:00
|
|
|
exports.path = /^\/admin\/post-role\/?$/;
|
2024-10-30 18:59:44 +01:00
|
|
|
|
2024-11-08 11:09:42 +01:00
|
|
|
exports.bodyFormat = "www-form-urlencoded";
|
2024-10-30 18:59:44 +01:00
|
|
|
|
2024-11-08 11:09:42 +01:00
|
|
|
exports.csrfDisable = true;
|
2024-10-30 18:59:44 +01:00
|
|
|
|
2024-11-08 11:09:42 +01:00
|
|
|
exports.handler = function (request, response, state) {
|
|
|
|
var sqlTiddlerDatabase = state.server.sqlTiddlerDatabase;
|
|
|
|
var role_name = state.data.role_name;
|
|
|
|
var role_description = state.data.role_description;
|
2024-10-30 18:59:44 +01:00
|
|
|
|
2024-11-08 11:09:42 +01:00
|
|
|
// Add your authentication check here if needed
|
2024-10-30 18:59:44 +01:00
|
|
|
|
2024-11-08 11:09:42 +01:00
|
|
|
sqlTiddlerDatabase.createRole(role_name, role_description);
|
2024-10-30 18:59:44 +01:00
|
|
|
|
2024-11-08 11:09:42 +01:00
|
|
|
response.writeHead(302, { "Location": "/admin/roles" });
|
|
|
|
response.end();
|
|
|
|
};
|
2024-10-30 18:59:44 +01:00
|
|
|
|
|
|
|
}());
|