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("main").innerHTML =
16 "Put the login screen here, dummary<br><br>" +
17 any_message + "<br><br>" +
18 _("User name:") + "<input type=\"text\" id=\"username\"><br>" +
19 _("Password:") + "<input type=\"password\" id=\"password\"><br>" +
20 "<a href=\"javascript:login_button()\">" + _("Log in") + "</a>"
29 var request = new XMLHttpRequest();
30 request.open("GET", "/ctdl/a/logout", true);
31 request.onreadystatechange = function() {
32 login_result(this.responseText);
39 function login_button(username)
42 document.getElementById("username").value
44 + document.getElementById("password").value
48 var request = new XMLHttpRequest();
49 request.open("POST", "/ctdl/a/login", true);
50 request.onreadystatechange = function() {
51 login_result(this.responseText);
58 function login_result(data)
60 if (data.substring(0,1) == "2") {
62 current_user = data.substring(4).split("|")[0];
64 document.getElementById("main").innerHTML = "FIXME ok we are logged in as " + current_user + " ... " ;
67 display_login_screen(data.substring(4));
72 // Detect whether the Citadel session is logged in as a user and update our internal variables accordingly.
74 function detect_logged_in()
76 var request = new XMLHttpRequest();
77 request.open("GET", "/ctdl/a/whoami", true);
78 request.onreadystatechange = function() {
79 detect_logged_in_2(this.responseText);
84 function detect_logged_in_2(data)
86 if (data.length > 0) {
92 current_user = _("Not logged in.");