]> code.citadel.org Git - citadel.git/blobdiff - webcit/auth.c
For sites in guest mode, redirect to the landing page after we're logged out.
[citadel.git] / webcit / auth.c
index 35c2063b3f2e14a22bb97d46d0df3a9c480956ce..dd015670499984a7b4303a0c1f47234ce108fe44 100644 (file)
@@ -64,7 +64,7 @@ void display_login(void)
 {
        begin_burst();
        output_headers(1, 0, 0, 0, 1, 0);
-       do_template("login", NULL);
+       do_template("login");
        end_burst();
 }
 
@@ -196,7 +196,7 @@ void openid_manual_create(void)
        if (havebstr("exit_action")) {
                begin_burst();
                output_headers(1, 0, 0, 0, 1, 0);
-               do_template("authpopup_finished", NULL);
+               do_template("authpopup_finished");
                end_burst();
                return;
        }
@@ -224,7 +224,7 @@ void openid_manual_create(void)
                if (WC->logged_in) {
                        begin_burst();
                        output_headers(1, 0, 0, 0, 1, 0);
-                       do_template("authpopup_finished", NULL);
+                       do_template("authpopup_finished");
                        end_burst();
                }
        } else {
@@ -237,7 +237,7 @@ void openid_manual_create(void)
                begin_burst();
                output_headers(1, 0, 0, 0, 1, 0);
                wc_printf("<html><body>");
-               do_template("openid_manual_create", NULL);
+               do_template("openid_manual_create");
                wc_printf("</body></html>");
                end_burst();
        }
@@ -364,7 +364,7 @@ void finalize_openid_login(void)
                if (WC->logged_in) {
                        begin_burst();
                        output_headers(1, 0, 0, 0, 1, 0);
-                       do_template("authpopup_finished", NULL);
+                       do_template("authpopup_finished");
                        end_burst();
                } else {
                        begin_burst();
@@ -389,7 +389,7 @@ void finalize_openid_login(void)
                begin_burst();
                output_headers(1, 0, 0, 0, 1, 0);
                wc_printf("<html><body>");
-               do_template("openid_manual_create", NULL);
+               do_template("openid_manual_create");
                wc_printf("</body></html>");
                end_burst();
        }
@@ -507,16 +507,19 @@ void do_logout(void)
        serv_getln(buf, sizeof buf);
        WCC->logged_in = 0;
 
-       if (WC->serv_info->serv_supports_guest) {
-               display_default_landing_page();
-               return;
-       }
-
        FlushStrBuf(WCC->CurRoom.name);
 
        /* Calling output_headers() this way causes the cookies to be un-set */
        output_headers(1, 1, 0, 1, 0, 0);
 
+       /* For sites in guest mode, redirect to the landing page after we're logged out */
+       if (WC->serv_info->serv_supports_guest) {
+               wc_printf("     <script type=\"text/javascript\">       "
+                       "       window.location='/';                    "
+                       "       </script>                               "
+               );
+       }
+
        wc_printf("<div id=\"logout_screen\">");
         wc_printf("<div class=\"box\">");
         wc_printf("<div class=\"boxlabel\">");
@@ -547,6 +550,46 @@ void do_logout(void)
        wc_printf(_("Log in again"));
        wc_printf("</a></span>");
        wc_printf("</div></div></div>\n");
+       if (WC->serv_info->serv_supports_guest) {
+               display_default_landing_page();
+               return;
+       }
+
+       wDumpContent(2);
+       end_webcit_session();
+}
+
+
+/* 
+ * Special page for monitoring scripts etc
+ */
+void monitor(void)
+{
+       wcsession *WCC = WC;
+       char buf[SIZ];
+
+       FlushStrBuf(WCC->wc_username);
+       FlushStrBuf(WCC->wc_password);
+       FlushStrBuf(WCC->wc_fullname);
+       FlushRoomlist();
+
+       serv_puts("LOUT");
+       serv_getln(buf, sizeof buf);
+       WCC->logged_in = 0;
+
+       FlushStrBuf(WCC->CurRoom.name);
+
+       /* Calling output_headers() this way causes the cookies to be un-set */
+       output_headers(1, 0, 0, 1, 1, 0);
+
+       wc_printf("<html><body><tt>");
+       wc_printf("<strong>WebCit monitoring screen</strong><br>\n");
+       wc_printf("Connection to Citadel server at %s:%s : %s<br>\n",
+               ctdlhost, ctdlport,
+               (WC->connected ? "SUCCESS" : "FAIL")
+       );
+       wc_printf("</body></html>\n");
+
        wDumpContent(2);
        end_webcit_session();
 }
@@ -564,9 +607,9 @@ void validate(void)
 
        output_headers(1, 1, 1, 0, 0, 0);
 
-        do_template("beginbox_1", NULL);
+        do_template("beginbox_1");
         StrBufAppendBufPlain(WC->WBuf, _("Validate new users"), -1, 0);
-        do_template("beginbox_2", NULL);
+        do_template("beginbox_2");
 
        /* If the user just submitted a validation, process it... */
        safestrncpy(buf, bstr("user"), sizeof buf);
@@ -680,7 +723,7 @@ void validate(void)
 
        wc_printf("</div>\n");
        wc_printf("</td></tr></table>\n");
-       do_template("endbox", NULL);
+       do_template("endbox");
        wDumpContent(1);
 }
 
@@ -792,7 +835,7 @@ void display_changepw(void)
        wc_printf("</div>\n");
        wc_printf("</form>\n");
 
-       do_template("endbox", NULL);
+       do_template("endbox");
        wDumpContent(1);
 }
 
@@ -1025,6 +1068,7 @@ InitModule_AUTH
        WebcitAddUrlHandler(HKEY("changepw"), "", 0, changepw, 0);
        WebcitAddUrlHandler(HKEY("termquit"), "", 0, do_logout, 0);
        WebcitAddUrlHandler(HKEY("do_logout"), "", 0, do_logout, ANONYMOUS|COOKIEUNNEEDED|FORCE_SESSIONCLOSE);
+       WebcitAddUrlHandler(HKEY("monitor"), "", 0, monitor, ANONYMOUS|COOKIEUNNEEDED|FORCE_SESSIONCLOSE);
        WebcitAddUrlHandler(HKEY("ajax_login_username_password"), "", 0, ajax_login_username_password, AJAX|ANONYMOUS);
        WebcitAddUrlHandler(HKEY("ajax_login_newuser"), "", 0, ajax_login_newuser, AJAX|ANONYMOUS);
        WebcitAddUrlHandler(HKEY("switch_language"), "", 0, switch_language, ANONYMOUS);