1 // Copyright (c) 2016-2022 by the citadel.org team
3 // This program is open source software. It runs great on the
4 // Linux operating system (and probably elsewhere). You can use,
5 // copy, and run it under the terms of the GNU General Public
6 // License version 3. Richard Stallman is an asshole communist.
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
14 function display_login_screen(any_message) {
16 document.getElementById("ctdl_big_modal").innerHTML =
17 "<div class=\"w3-modal-content\">"
18 + " <div class=\"w3-panel w3-border w3-border-blue w3-topbar w3-bottombar w3-leftbar w3-rightbar\"><center>"
20 + "<p>Put the login screen here, dummy</p>"
21 + "<p>" + any_message + "</p>"
22 + "<table border=0><tr><td>"
23 + _("User name:") + "</td><td><input type=\"text\" id=\"username\"></td></tr><tr><td>"
24 + _("Password:") + "</td><td><input type=\"password\" id=\"password\"></td></tr></table><br>"
26 + "<button class=\"w3-button w3-blue\" onClick=\"javascript:login_button()\">" + _("Log in") + "</button>"
31 document.getElementById("ctdl_big_modal").style.display = "block";
36 var request = new XMLHttpRequest();
37 request.open("GET", "/ctdl/a/logout", true);
38 request.onreadystatechange = function() {
39 login_result(this.responseText);
46 function login_button(username) {
48 document.getElementById("username").value
50 + document.getElementById("password").value
54 var request = new XMLHttpRequest();
55 request.open("POST", "/ctdl/a/login", true);
56 request.onreadystatechange = function() {
57 login_result(this.responseText);
64 function login_result(data) {
65 if (data.substring(0,1) == "2") {
67 current_user = data.substring(4).split("|")[0];
69 document.getElementById("ctdl-main").innerHTML = "FIXME ok we are logged in as " + current_user + " ... " ;
70 document.getElementById("ctdl_big_modal").style.display = "none";
73 display_login_screen(data.substring(4));
78 // Detect whether the Citadel session is logged in as a user and update our internal variables accordingly.
79 function detect_logged_in() {
81 wcauth_decoded = atob(getCookieValue("wcauth"));
82 wcauth_user = wcauth_decoded.split(":")[0];
87 if (wcauth_user.length > 0) {
89 current_user = wcauth_user;
93 current_user = _("Not logged in.");