1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-09 11:29:58 +00:00
TiddlyWiki5/core/modules/server/routes/get-status.js
jeremy@jermolene.com 95e6168839 Fix logout triggering 404 error
See https://talk.tiddlywiki.org/t/logout-error-xmlhttprequest-error-code-404/5590/5 for details

We can't POST to the logout endpoint without triggering authentication, so we report in advance whether logout is supported.
2022-12-24 12:13:01 +00:00

34 lines
747 B
JavaScript

/*\
title: $:/core/modules/server/routes/get-status.js
type: application/javascript
module-type: route
GET /status
\*/
(function() {
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
exports.method = "GET";
exports.path = /^\/status$/;
exports.handler = function(request,response,state) {
var text = JSON.stringify({
username: state.authenticatedUsername || state.server.get("anon-username") || "",
anonymous: !state.authenticatedUsername,
read_only: !state.server.isAuthorized("writers",state.authenticatedUsername),
logout_is_available: false,
space: {
recipe: "default"
},
tiddlywiki_version: $tw.version
});
state.sendResponse(200,{"Content-Type": "application/json"},text,"utf8");
};
}());