2 // Copyright (c) 2016-2020 by the citadel.org team
4 // This program is open source software. It runs great on the
5 // Linux operating system (and probably elsewhere). You can use,
6 // copy, and run it under the terms of the GNU General Public
7 // License version 3. Richard Stallman is an asshole communist.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
15 function display_login_screen(any_message)
17 document.getElementById("ctdl-main").innerHTML =
18 "<center><br><br>Put the login screen here, dummary<br><br>" +
19 any_message + "<br><br>" +
20 "<table border=0><tr><td>" +
21 _("User name:") + "</td><td><input type=\"text\" id=\"username\"></td></tr><tr><td>" +
22 _("Password:") + "</td><td><input type=\"password\" id=\"password\"></td></tr></table><br>" +
23 "<a href=\"javascript:login_button()\">" + _("Log in") + "</a></center>"
32 var request = new XMLHttpRequest();
33 request.open("GET", "/ctdl/a/logout", true);
34 request.onreadystatechange = function() {
35 login_result(this.responseText);
42 function login_button(username)
45 document.getElementById("username").value
47 + document.getElementById("password").value
51 var request = new XMLHttpRequest();
52 request.open("POST", "/ctdl/a/login", true);
53 request.onreadystatechange = function() {
54 login_result(this.responseText);
61 function login_result(data)
63 if (data.substring(0,1) == "2") {
65 current_user = data.substring(4).split("|")[0];
67 document.getElementById("ctdl-main").innerHTML = "FIXME ok we are logged in as " + current_user + " ... " ;
70 display_login_screen(data.substring(4));
75 // Detect whether the Citadel session is logged in as a user and update our internal variables accordingly.
77 function detect_logged_in()
79 var request = new XMLHttpRequest();
80 request.open("GET", "/ctdl/a/whoami", true);
81 request.onreadystatechange = function() {
82 detect_logged_in_2(this.responseText);
87 function detect_logged_in_2(data)
89 if (data.length > 0) {
95 current_user = _("Not logged in.");