Initial version of modal login is now working.
authorArt Cancro <ajc@citadel.org>
Wed, 29 Dec 2010 22:34:21 +0000 (17:34 -0500)
committerWilfried Goesgens <dothebart@citadel.org>
Sun, 4 Sep 2011 13:32:04 +0000 (13:32 +0000)
webcit/auth.c
webcit/static/authmethods.js [new file with mode: 0644]
webcit/static/instant_messenger.html
webcit/static/t/aide/display_serverrestart.html
webcit/static/t/aide/display_serverrestart_page_do.html
webcit/static/t/get_logged_in.html
webcit/static/t/head.html
webcit/static/wclib.js

index 6bf872dbb8f06f79c69fcd715793522c16e7af26..435850113ff355ac8706c2158662a95c2b6bd1c4 100644 (file)
@@ -248,7 +248,7 @@ void do_login(void)
  * modal/ajax version of 'login' (username and password)
  */
 void ajax_login_username_password(void) {
-       StrBuf *Buf;
+       StrBuf *Buf = NewStrBuf();
 
        serv_printf("USER %s", bstr("name"));
        StrBuf_ServGetln(Buf);
@@ -257,12 +257,11 @@ void ajax_login_username_password(void) {
                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));
-
+       /* The client is expecting to read back a citadel protocol response */
+       wc_printf("%s", ChrPtr(Buf));
        FreeStrBuf(&Buf);
 }
 
@@ -1092,7 +1091,7 @@ InitModule_AUTH
        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);
-       return ;
+       return;
 }
 
 
diff --git a/webcit/static/authmethods.js b/webcit/static/authmethods.js
new file mode 100644 (file)
index 0000000..2665351
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2010, the Citadel Team
+ * Licensed under the GPL V3
+ *
+ * JavaScript functions which handle various authentication methods.
+ */
+
+
+/*
+ * Wrapper script to require logging in before completing an action
+ */
+function GetLoggedInFirst(destination_url) {
+
+       /* If logged in already, go directly to the destination. */
+       /* FIXME implement this */
+
+       /* If not logged in, go modal and ask the user to log in first. */
+       p = 'do_template?template=get_logged_in?destination_url=' + destination_url;
+       new Ajax.Updater(
+               'md-content',
+               p,
+                {
+                        method: 'get',
+                       onSuccess: function(cl_success) {
+                               toggleModal(1);
+                       }
+                }
+        );
+}
+
+
+/*
+ * Attempt login with username/password, called from modal dialog
+ */
+function ajax_try_username_and_password(destination_url) {
+       $('login_errmsg').innerHTML = "";
+        $('ajax_username_password_form').request({
+               onSuccess: function(ctdlresult) {
+                       if (ctdlresult.responseText.substr(0,1) == '2') {
+                               window.location = destination_url;
+                       }
+                       else {
+                               $('login_errmsg').innerHTML = ctdlresult.responseText.substr(4) ;
+                       }
+               }
+       });
+}
index eb8add9f2131ceb9d4f69d1e9a7045560e190e11..549e6a29475ef37ece52c4accc2de23e0ad4c284 100644 (file)
@@ -3,6 +3,7 @@
        <title>Citadel Instant Messenger</title>
        <script type="text/javascript" src="prototype.js"></script>
        <script type="text/javascript" src="wclib.js"></script>
+       <script type="text/javascript" src="authmethods.js"></script>
 </head>
 <body onLoad='FetchNewMsgs();'>
 
index bd96ccb1409beaa6b862d59386cc91cd83b84c48..f9b63bef706fb0eee614c7d6e06ab823b46508fb 100644 (file)
@@ -15,6 +15,7 @@
                <script type="text/javascript" src="static/datepicker-dev.js"></script>
                <script type="text/javascript" src="static/table.js"></script>
                <script type="text/javascript" src="static/wclib.js"></script>
+               <script type="text/javascript" src="static/authmethods.js"></script>
                <meta http-equiv="refresh" content="15; URL=do_template?template=aide_display_menu"/>
        </head>
 <body>
index 12053d3ed608bfd438520aa31af9110c4ece2b9c..2c323155e4b02dbe57ceb657189d8b817b684bb9 100644 (file)
@@ -15,6 +15,7 @@
                <script type="text/javascript" src="static/datepicker-dev.js"></script>
                <script type="text/javascript" src="static/table.js"></script>
                <script type="text/javascript" src="static/wclib.js"></script>
+               <script type="text/javascript" src="static/authmethods.js"></script>
                <meta http-equiv="refresh" content="40; URL=server_shutdown?when=now"/>
        </head>
 <body>
index 518882052c86e43c4c2c9240e4f4ef67545a0fe3..0112971dc13b332badf5b5650175d1828cd9a02b 100644 (file)
@@ -4,9 +4,10 @@
 <a href="javascript:toggleModal(0);"><img src="static/closewindow.gif" border="0"></a>
 </div>
 <div align="center">
-To complete this action, you must log in.<br>
+To complete this action, you must log in.  FIXME localize this string.<br>
+<div class="login_message" id="login_errmsg"></div>
 <hr>
-<form method="POST" id="ajax_login_username_password">
+<form id="ajax_username_password_form" method="POST" action="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>
@@ -16,7 +17,7 @@ To complete this action, you must log in.<br>
 </tr></table>
 </form>
 <hr>
-<a href="<?BSTR("destination_url")>">Proceed and fail</a><br>
+<a href="javascript:ajax_try_username_and_password('<?BSTR("destination_url")>');">Proceed and be clueless</a><br>
 <a href="javascript:toggleModal(0);"><?_("Cancel")></a>
 </div>
 </body>
index ab9e593f119e6a20946e03d1573febae456d6def..60d1053c13c41b05b884a25585c1378547f4c65d 100644 (file)
@@ -20,6 +20,7 @@
                <script type="text/javascript" src="static/wcpref.js"></script>
                <script type="text/javascript" src="static/table.js"></script>
                <script type="text/javascript" src="static/wclib.js"></script>
+               <script type="text/javascript" src="static/authmethods.js"></script>
                <script type="text/javascript" src="static/roomops.js"></script>
                <script type="text/javascript" src="static/ctdldragdrop.js"></script>
                <script type="text/javascript" src="static/modal.js"></script>
index 889b068e70f11b1b96ebec0c632263bc52096771..7a85697ecaad8823adb72c62b049d2a84b09d563 100644 (file)
@@ -875,26 +875,3 @@ function ConfirmLogoff() {
                 }
         );
 }
-
-
-/*
- * Wrapper script to require logging in before completing an action
- */
-function GetLoggedInFirst(destination_url) {
-
-       /* If logged in already, go directly to the destination. */
-       /* FIXME implement this */
-
-       /* If not logged in, go modal and ask the user to log in first. */
-       p = 'do_template?template=get_logged_in?destination_url=' + destination_url;
-       new Ajax.Updater(
-               'md-content',
-               p,
-                {
-                        method: 'get',
-                       onSuccess: function(cl_success) {
-                               toggleModal(1);
-                       }
-                }
-        );
-}