From 91d14cf3c8874cf7d08b542e090b5eff2bc4208f Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Mon, 24 Jan 2011 13:38:29 -0500 Subject: [PATCH] Began implementation of authpopout --- webcit/auth.c | 41 ++++++++++-------------------- webcit/static/authmethods.js | 20 +++++++++++++++ webcit/static/t/get_logged_in.html | 1 + 3 files changed, 34 insertions(+), 28 deletions(-) diff --git a/webcit/auth.c b/webcit/auth.c index 74ab66738..325c84725 100644 --- a/webcit/auth.c +++ b/webcit/auth.c @@ -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 diff --git a/webcit/static/authmethods.js b/webcit/static/authmethods.js index 4bb117c61..1ea70c00d 100644 --- a/webcit/static/authmethods.js +++ b/webcit/static/authmethods.js @@ -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); +} + diff --git a/webcit/static/t/get_logged_in.html b/webcit/static/t/get_logged_in.html index 568f4c186..3d9a5a926 100644 --- a/webcit/static/t/get_logged_in.html +++ b/webcit/static/t/get_logged_in.html @@ -54,6 +54,7 @@ +
-- 2.30.2