2 // Copyright (c) 2016-2017 by the citadel.org team
4 // This program is open source software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License version 3.
7 // This program is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 // GNU General Public License for more details.
13 function display_login_screen(any_message)
15 document.getElementById("ctdl-main").innerHTML =
16 "<center><br><br>Put the login screen here, dummary<br><br>" +
17 any_message + "<br><br>" +
18 "<table border=0><tr><td>" +
19 _("User name:") + "</td><td><input type=\"text\" id=\"username\"></td></tr><tr><td>" +
20 _("Password:") + "</td><td><input type=\"password\" id=\"password\"></td></tr></table><br>" +
21 "<a href=\"javascript:login_button()\">" + _("Log in") + "</a></center>"
30 var request = new XMLHttpRequest();
31 request.open("GET", "/ctdl/a/logout", true);
32 request.onreadystatechange = function() {
33 login_result(this.responseText);
40 function login_button(username)
43 document.getElementById("username").value
45 + document.getElementById("password").value
49 var request = new XMLHttpRequest();
50 request.open("POST", "/ctdl/a/login", true);
51 request.onreadystatechange = function() {
52 login_result(this.responseText);
59 function login_result(data)
61 if (data.substring(0,1) == "2") {
63 current_user = data.substring(4).split("|")[0];
65 document.getElementById("ctdl-main").innerHTML = "FIXME ok we are logged in as " + current_user + " ... " ;
68 display_login_screen(data.substring(4));
73 // Detect whether the Citadel session is logged in as a user and update our internal variables accordingly.
75 function detect_logged_in()
77 var request = new XMLHttpRequest();
78 request.open("GET", "/ctdl/a/whoami", true);
79 request.onreadystatechange = function() {
80 detect_logged_in_2(this.responseText);
85 function detect_logged_in_2(data)
87 if (data.length > 0) {
93 current_user = _("Not logged in.");