]> code.citadel.org Git - citadel.git/blobdiff - webcit/auth.c
* add new 'Context' Parameter to the template call
[citadel.git] / webcit / auth.c
index d85ad0cb2c09bf377caf807c2d356d8a21a47462..0b01a16b8ebea184aa3fec6277dbd84e832abab4 100644 (file)
@@ -8,6 +8,9 @@
 #include "webserver.h"
 #include <ctype.h>
 
+
+void display_reg(int during_login);
+
 /*
  * Access level definitions.  This is initialized from a function rather than a
  * static array so that the strings may be localized.
@@ -94,7 +97,7 @@ void display_login(char *mesg)
                svput("OFFER_OPENID_LOGIN", WCS_STRING, "");
        }
 
-       do_template("login");
+       do_template("login", NULL);
 
        wDumpContent(2);
 }
@@ -150,7 +153,7 @@ void display_openid_login(char *mesg)
                "Log in using a user name and password"
        );
 
-       do_template("openid_login");
+       do_template("openid_login", NULL);
        wDumpContent(2);
 }
 
@@ -185,7 +188,7 @@ void display_openid_name_request(char *claimed_id, char *username) {
        svprintf(HKEY("BOXTITLE"), WCS_STRING, _("%s - powered by <a href=\"http://www.citadel.org\">Citadel</a>"),
                serv_info.serv_humannode);
 
-       do_template("openid_manual_create");
+       do_template("openid_manual_create", NULL);
        wDumpContent(2);
 }
 
@@ -283,6 +286,7 @@ void do_login(void)
                }
        }
        if (WC->logged_in) {
+               set_preference("language", NewStrBufPlain(bstr("language"), -1), 1);
                if (WC->need_regi) {
                        display_reg(1);
                } else if (WC->need_vali) {
@@ -408,7 +412,7 @@ void finalize_openid_login(void)
                                while (GetNextHashPos(WCC->urlstrings, Cursor, &HKLen, &HKey, &U)) {
                                        u = (urlcontent*) U;
                                        if (!strncasecmp(u->url_key, "openid.", 7)) {
-                                               serv_printf("%s|%s", &u->url_key[7], u->url_data);
+                                               serv_printf("%s|%s", &u->url_key[7], ChrPtr(u->url_data));
                                        }
                                }
 
@@ -536,6 +540,8 @@ void do_welcome(void)
        if (ChrPtr(Buf)[0] == '/') {
                StrBufCutLeft(Buf, 1);
        }
+       if (StrLength(Buf) == 0)
+               StrBufAppendBufPlain(Buf, "dotgoto?room=_BASEROOM_", -1, 0);
        http_redirect(ChrPtr(Buf));
 }
 
@@ -789,7 +795,7 @@ void display_changepw(void)
        output_headers(1, 1, 1, 0, 0, 0);
 
        svput("BOXTITLE", WCS_STRING, _("Change your password"));
-       do_template("beginbox");
+       do_template("beginbox", NULL);
 
        if (!IsEmptyStr(WC->ImportantMessage)) {
                wprintf("<span class=\"errormsg\">"
@@ -823,7 +829,7 @@ void display_changepw(void)
        wprintf("</div>\n");
        wprintf("</form>\n");
 
-       do_template("endbox");
+       do_template("endbox", NULL);
        wDumpContent(1);
 }
 
@@ -875,10 +881,25 @@ void changepw(void)
        }
 }
 
+void _display_openid_login(void) {display_openid_login(NULL);}
+void _display_reg(void) {display_reg(0);}
 
 
-void InitModule_AUTH(void)
+void 
+InitModule_AUTH
+(void)
 {
-       WebcitAddUrlHandler(HKEY("do_welcome"), do_welcome, 0);
+       WebcitAddUrlHandler(HKEY("do_welcome"), do_welcome, ANONYMOUS);
+       WebcitAddUrlHandler(HKEY("login"), do_login, ANONYMOUS);
+       WebcitAddUrlHandler(HKEY("display_openid_login"), _display_openid_login, ANONYMOUS);
+       WebcitAddUrlHandler(HKEY("openid_login"), do_openid_login, ANONYMOUS);
+       WebcitAddUrlHandler(HKEY("finalize_openid_login"), finalize_openid_login, ANONYMOUS);
+       WebcitAddUrlHandler(HKEY("openid_manual_create"), openid_manual_create, ANONYMOUS);
+       WebcitAddUrlHandler(HKEY("do_logout"), do_logout, 0);
+       WebcitAddUrlHandler(HKEY("validate"), validate, 0);
+       WebcitAddUrlHandler(HKEY("display_reg"), _display_reg, 0);
+       WebcitAddUrlHandler(HKEY("display_changepw"), display_changepw, 0);
+       WebcitAddUrlHandler(HKEY("changepw"), changepw, 0);
+       WebcitAddUrlHandler(HKEY("termquit"), do_logout, 0);
        return ;
 }