Wrote the initial version of the 'ajax_login_username_password' handler
authorArt Cancro <ajc@citadel.org>
Wed, 29 Dec 2010 18:55:02 +0000 (13:55 -0500)
committerWilfried Goesgens <dothebart@citadel.org>
Sun, 4 Sep 2011 13:31:56 +0000 (13:31 +0000)
webcit/auth.c
webcit/static/t/get_logged_in.html

index 56923f4983a6e0b81e469180e8416e531cf86048..6bf872dbb8f06f79c69fcd715793522c16e7af26 100644 (file)
@@ -242,6 +242,32 @@ void do_login(void)
        FreeStrBuf(&Buf);
 }
 
+
+
+/* 
+ * modal/ajax version of 'login' (username and password)
+ */
+void ajax_login_username_password(void) {
+       StrBuf *Buf;
+
+       serv_printf("USER %s", bstr("name"));
+       StrBuf_ServGetln(Buf);
+       if (GetServerStatus(Buf, NULL) == 3) {
+               serv_printf("PASS %s", bstr("pass"));
+               StrBuf_ServGetln(Buf);
+               if (GetServerStatus(Buf, NULL) == 2) {
+                       become_logged_in(sbstr("name"), sbstr("pass"), Buf);
+                       wc_printf("FIXME success");
+               }
+       }
+
+       wc_printf("FIXME %s", ChrPtr(Buf));
+
+       FreeStrBuf(&Buf);
+}
+
+
+
 /* 
  * Try to create an account manually after an OpenID was verified
  */
@@ -1055,12 +1081,14 @@ InitModule_AUTH
        WebcitAddUrlHandler(HKEY("finalize_openid_login"), "", 0, finalize_openid_login, ANONYMOUS);
        WebcitAddUrlHandler(HKEY("openid_manual_create"), "", 0, openid_manual_create, ANONYMOUS);
        WebcitAddUrlHandler(HKEY("do_logout"), "", 0, do_logout, ANONYMOUS|COOKIEUNNEEDED|FORCE_SESSIONCLOSE);
+       WebcitAddUrlHandler(HKEY("ajax_login_username_password"), "", 0, ajax_login_username_password, AJAX);
        WebcitAddUrlHandler(HKEY("validate"), "", 0, validate, 0);
        WebcitAddUrlHandler(HKEY("display_reg"), "", 0, _display_reg, 0);
        WebcitAddUrlHandler(HKEY("display_changepw"), "", 0, display_changepw, 0);
        WebcitAddUrlHandler(HKEY("changepw"), "", 0, changepw, 0);
        WebcitAddUrlHandler(HKEY("termquit"), "", 0, do_logout, 0);
 
+
        RegisterConditional(HKEY("COND:AIDE"), 2, ConditionalAide, CTX_NONE);
        RegisterConditional(HKEY("COND:LOGGEDIN"), 2, ConditionalIsLoggedIn, CTX_NONE);
        RegisterConditional(HKEY("COND:MAY_CREATE_ROOM"), 2,  ConditionalHaveAccessCreateRoom, CTX_NONE);
index 3f6986470c90a66f87b817802073b36f3f473077..518882052c86e43c4c2c9240e4f4ef67545a0fe3 100644 (file)
@@ -6,7 +6,7 @@
 <div align="center">
 To complete this action, you must log in.<br>
 <hr>
-<form method="POST" id="ajax_login_form">
+<form method="POST" id="ajax_login_username_password">
 <table border=0 cellspacing=0 cellpadding=0><tr>
 <td><?_("User name:")></td>
 <td><input type="text" name="name" id="uname"></td>