-//
-// Copyright (c) 2016-2020 by the citadel.org team
+// Copyright (c) 2016-2022 by the citadel.org team
//
// This program is open source software. It runs great on the
// Linux operating system (and probably elsewhere). You can use,
// GNU General Public License for more details.
-function display_login_screen(any_message)
-{
- document.getElementById("ctdl-main").innerHTML =
- "<center><br><br>Put the login screen here, dummary<br><br>" +
- any_message + "<br><br>" +
- "<table border=0><tr><td>" +
- _("User name:") + "</td><td><input type=\"text\" id=\"username\"></td></tr><tr><td>" +
- _("Password:") + "</td><td><input type=\"password\" id=\"password\"></td></tr></table><br>" +
- "<a href=\"javascript:login_button()\">" + _("Log in") + "</a></center>"
- ;
+function display_login_screen(any_message) {
+
+ document.getElementById("ctdl_big_modal").innerHTML =
+ "<div class=\"w3-modal-content\">"
+ + " <div class=\"w3-container\">"
+
+ + "Put the login screen here, dummy<br><br>"
+ + any_message + "<br><br>"
+ + "<table border=0><tr><td>"
+ + _("User name:") + "</td><td><input type=\"text\" id=\"username\"></td></tr><tr><td>"
+ + _("Password:") + "</td><td><input type=\"password\" id=\"password\"></td></tr></table><br>"
+ + "<a href=\"javascript:login_button()\">" + _("Log in") + "</a>"
- update_banner();
+ + " </div>"
+ + "</div>";
+ document.getElementById("ctdl_big_modal").style.display = "block";
}
-function logout()
-{
+function logout() {
var request = new XMLHttpRequest();
request.open("GET", "/ctdl/a/logout", true);
request.onreadystatechange = function() {
}
-function login_button(username)
-{
+function login_button(username) {
parms =
document.getElementById("username").value
+ "|"
}
-function login_result(data)
-{
+function login_result(data) {
if (data.substring(0,1) == "2") {
logged_in = 1;
current_user = data.substring(4).split("|")[0];
update_banner();
document.getElementById("ctdl-main").innerHTML = "FIXME ok we are logged in as " + current_user + " ... " ;
+ document.getElementById("ctdl_big_modal").style.display = "none";
}
else {
display_login_screen(data.substring(4));
// Detect whether the Citadel session is logged in as a user and update our internal variables accordingly.
-//
-function detect_logged_in()
-{
- var request = new XMLHttpRequest();
- request.open("GET", "/ctdl/a/whoami", true);
- request.onreadystatechange = function() {
- detect_logged_in_2(this.responseText);
- };
- request.send();
- request = null;
-}
-function detect_logged_in_2(data)
-{
- if (data.length > 0) {
+function detect_logged_in() {
+ try {
+ wcauth_decoded = atob(getCookieValue("wcauth"));
+ wcauth_user = wcauth_decoded.split(":")[0];
+ }
+ catch(err) {
+ wcauth_user = "";
+ }
+ if (wcauth_user.length > 0) {
logged_in = 1;
- current_user = data;
+ current_user = wcauth_user;
}
else {
logged_in = 0;