]> code.citadel.org Git - citadel.git/blobdiff - webcit/static/authmethods.js
Initial version of modal login is now working.
[citadel.git] / webcit / static / authmethods.js
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) ;
+                       }
+               }
+       });
+}