From 786e916940011d853b219f8d6f32c053d6aafc07 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Wed, 29 Dec 2010 17:34:21 -0500 Subject: [PATCH] Initial version of modal login is now working. --- webcit/auth.c | 9 ++-- webcit/static/authmethods.js | 47 +++++++++++++++++++ webcit/static/instant_messenger.html | 1 + .../static/t/aide/display_serverrestart.html | 1 + .../t/aide/display_serverrestart_page_do.html | 1 + webcit/static/t/get_logged_in.html | 7 +-- webcit/static/t/head.html | 1 + webcit/static/wclib.js | 23 --------- 8 files changed, 59 insertions(+), 31 deletions(-) create mode 100644 webcit/static/authmethods.js diff --git a/webcit/auth.c b/webcit/auth.c index 6bf872dbb..435850113 100644 --- a/webcit/auth.c +++ b/webcit/auth.c @@ -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 index 000000000..266535176 --- /dev/null +++ b/webcit/static/authmethods.js @@ -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) ; + } + } + }); +} diff --git a/webcit/static/instant_messenger.html b/webcit/static/instant_messenger.html index eb8add9f2..549e6a294 100644 --- a/webcit/static/instant_messenger.html +++ b/webcit/static/instant_messenger.html @@ -3,6 +3,7 @@ Citadel Instant Messenger + diff --git a/webcit/static/t/aide/display_serverrestart.html b/webcit/static/t/aide/display_serverrestart.html index bd96ccb14..f9b63bef7 100644 --- a/webcit/static/t/aide/display_serverrestart.html +++ b/webcit/static/t/aide/display_serverrestart.html @@ -15,6 +15,7 @@ + diff --git a/webcit/static/t/aide/display_serverrestart_page_do.html b/webcit/static/t/aide/display_serverrestart_page_do.html index 12053d3ed..2c323155e 100644 --- a/webcit/static/t/aide/display_serverrestart_page_do.html +++ b/webcit/static/t/aide/display_serverrestart_page_do.html @@ -15,6 +15,7 @@ + diff --git a/webcit/static/t/get_logged_in.html b/webcit/static/t/get_logged_in.html index 518882052..0112971dc 100644 --- a/webcit/static/t/get_logged_in.html +++ b/webcit/static/t/get_logged_in.html @@ -4,9 +4,10 @@
-To complete this action, you must log in.
+To complete this action, you must log in. FIXME localize this string.
+
-
+ @@ -16,7 +17,7 @@ To complete this action, you must log in.

-">Proceed and fail
+');">Proceed and be clueless
diff --git a/webcit/static/t/head.html b/webcit/static/t/head.html index ab9e593f1..60d1053c1 100644 --- a/webcit/static/t/head.html +++ b/webcit/static/t/head.html @@ -20,6 +20,7 @@ + diff --git a/webcit/static/wclib.js b/webcit/static/wclib.js index 889b068e7..7a85697ec 100644 --- a/webcit/static/wclib.js +++ b/webcit/static/wclib.js @@ -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); - } - } - ); -} -- 2.30.2