Began implementation of authpopout
authorArt Cancro <ajc@citadel.org>
Mon, 24 Jan 2011 18:38:29 +0000 (13:38 -0500)
committerWilfried Goesgens <dothebart@citadel.org>
Sun, 4 Sep 2011 14:03:47 +0000 (14:03 +0000)
webcit/auth.c
webcit/static/authmethods.js
webcit/static/t/get_logged_in.html

index 74ab667385cfdce1ada3dd4a30330839a6d54544..325c84725547738b50f876e97dd02b544a8bd838 100644 (file)
@@ -313,40 +313,25 @@ void do_openid_login(void)
 {
        char buf[4096];
 
-       if (havebstr("language")) {
-               set_selected_language(bstr("language"));
-               go_selected_language();
-       }
+       snprintf(buf, sizeof buf,
+               "OIDS %s|%s/finalize_openid_login|%s",
+               bstr("openid_url"),
+               ChrPtr(site_prefix),
+               ChrPtr(site_prefix)
+       );
 
-       if (havebstr("exit_action")) {
-               do_logout();
+       serv_puts(buf);
+       serv_getln(buf, sizeof buf);
+       if (buf[0] == '2') {
+               syslog(LOG_DEBUG, "OpenID server contacted; redirecting to %s\n", &buf[4]);
+               http_redirect(&buf[4]);
                return;
        }
-       if (havebstr("login_action")) {
-               snprintf(buf, sizeof buf,
-                       "OIDS %s|%s/finalize_openid_login|%s",
-                       bstr("openid_url"),
-                       ChrPtr(site_prefix),
-                       ChrPtr(site_prefix)
-               );
-
-               serv_puts(buf);
-               serv_getln(buf, sizeof buf);
-               if (buf[0] == '2') {
-                       syslog(LOG_DEBUG, "OpenID server contacted; redirecting to %s\n", &buf[4]);
-                       http_redirect(&buf[4]);
-                       return;
-               }
-               else {
-                       display_login();
-                       return;
-               }
-       }
 
-       /* If we get to this point then something failed. */
-       display_login();
+       convenience_page("770000", _("Error"), &buf[4]);
 }
 
+
 /* 
  * Complete the authentication using OpenID
  * This function handles the positive or negative assertion from the user's Identity Provider
index 4bb117c61754347bfae5336af1268757eb1e7ea0..1ea70c00de969628ba684e55edd76a3aceb96d83 100644 (file)
@@ -91,3 +91,23 @@ function authtoggle(show_which_div) {
        $('authbox_openid').style.display = 'none';
        $(show_which_div).style.display = 'block';
 }
+
+
+/*
+ * Pop out a window for external auth methods
+ * (most of them don't handle inline auth very well)
+ */
+function do_auth_popout(popout_url) {
+       window.open(popout_url, "authpopout", "status=1,toolbar=0,width=600,height=400");
+}
+
+
+/*
+ * Attempt login with OpenID, called from modal dialog
+ */
+function ajax_try_openid() {
+       $('login_errmsg').innerHTML = "";
+       openid_url = encodeURI($('ajax_openid_form').elements["openid_url"].value);
+       do_auth_popout("openid_login?openid_url=" + openid_url);
+}
+
index 568f4c186ed8dec8ce7d2401e21e67d2bd1a8817..3d9a5a92656e85c6cd8757a8a44b45e23fda1b4d 100644 (file)
@@ -54,6 +54,7 @@
 <?_("OpenID URL:")>
 <input type="text" name="openid_url" id="openid_url" class="openid_urlarea">
 </form>
+<div class="buttons"><a href="javascript:ajax_try_openid();"><?_("Log in")></a></div>
 </div>
 
 </div>